<!-- eslint-disable InnerIPLeak -->
<!-- eslint-disable max-len -->
<template>
  <div class="h100 EditSoftwareManageAndControl">
    <!-- 操作栏 -->
    <!-- <div class="navigator">
      <swSteps/>
    </div> -->
    <div class="navigator" style="width:100%;display:flex;">
      <div style="transform:scale(0.9);margin-left:-20px;flex:1">
        <swSteps :activeIndex="activeIndex"/>
      </div>
      <div v-if="fromApplication || from" style="transform:scale(0.9);display:flex;margin-right:10px">
        <div style="display:flex;">
          <div style="display:flex;flex-direction: column">
            <a-button style="margin-bottom: 20px" v-if="status==30">
              <span class="titleBold">{{ $t('formStatus')+"：" }}</span>
              <span class="reject titleBold">{{ $t('rejected') }}</span>
            </a-button>
            <a-button style="margin-bottom: 20px" v-if="status==40">
              <span class="titleBold">{{ $t('formStatus')+"：" }}</span>
              <span class="reject titleBold">{{ $t('sqych') }}</span>
            </a-button>
            <a-button style="">
              <span class="titleBold ">{{ $t('completeTime')+"：" }}</span>
              <span class="ok titleBold">{{ endTime }}</span>
            </a-button>
          </div>
        </div>
        <div style="display:flex;flex-direction: column;margin-left: 10px">
          <div>
            <auth-button @click="handleSubmit" style="margin-bottom: 20px;width:95%" :loading="saving">{{ '重新提交' }}</auth-button>
          </div>
          <div>
            <auth-button type="primary" :ghost="true" @click="cancelReeditAction" v-if="from">
              {{ $t('cancel') }}
            </auth-button >
            <auth-button type="primary" :ghost="true" @click="cancelReedit" v-else>
              {{ $t('cancel') }}
            </auth-button >
            <auth-button type="danger" style="margin-left: 10px" @click="fz" :auth="todoPerms.apply.repealInstance">
              {{ $t('repeal') }}
            </auth-button >
          </div>
        </div>
      </div>
      <div v-else style="transform:scale(0.9);margin-top:30px;">
        <a-button style="margin-right: 10px" @click="handleCancel">{{ $t('cancel') }}</a-button>
        <auth-button style="margin-right: 10px" @click="handleSubmitAsDraft" :disabled="disableSaveDraft">{{ $t('saveAsDraft') }}</auth-button>
        <auth-button @click="handleSubmit" :loading="saving">{{ $t('save') }}</auth-button>
      </div>
    </div>
    <!-- 软件管控新建表单/草稿编辑/加工失败表单编辑页面 -->
    <div class="EditSoftwareMCTop" style="background:#ECECEC;" ref="box" @scroll="handleScroll($event)">
      <a-form-model
        class="AsteriskAfter newEditStyle detailPaddingPage"
        style="display: flex; flex-direction: column"
        :layout="formLayout"
        labelAlign="left"
        ref="newEditForm"
        :rules="rules"
        :model="formData"
        v-bind="formItemLayout"
        :colon="false">
        <!-- 基本信息 -->
        <a-card class="card-radius" id="sw-step-1">
          <!-- <p  class="customFormModelItem2">{{ $t('basicInformation') }}</p> -->
          <a-form-model-item>
            <a-row :gutter="[36,10]">
              <!-- 车型 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item prop="modelCode">
                    <span slot="label">
                      <span class="requiredStar">*</span>
                      {{ $t('vehicleModel1') }}
                    </span>
                  <!--: 数据量过大，过滤改为后端实现 filter-option="filterOption"  option-filter-prop="children"-->
                      <a-select
                        v-model="formData.modelCode"
                        :disabled="noEditModel||onlineDifference"
                        showSearch
                        style="width:100%"
                        @search="getModelData"
                        @blur="getModelData('')"
                        mode="default"
                        :filterOption="false"
                        @change="handleCarModelChange"
                        :placeholder="$t('pleaseSelect') + $t('vehicleModel')"
                      >
                        <a-select-option
                          v-for="item in carModelArr"
                          :key="item.value"
                        >{{ item.value + '[' + item.name + ']' }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- ECU名称 -->
              <a-col :md="8" :sm="24">
                    <!-- <a-form-model-item prop="ecuId" :label="$t('ecuName')"> -->
                    <a-form-model-item prop="ecuId">
                      <span slot="label">
                        <span class="requiredStar">*</span>
                        {{ $t('ecuName') }}
                      </span>
                      <a-select
                        v-model="formData.ecuId"
                        :disabled="!formData.modelCode||onlineDifference"
                        showSearch
                        optionFilterProp="children"
                        :filterOption="$commonFun.filterOption"
                        :placeholder="$t('pleaseSelect')+$t('partName')"
                        style="width:100%"
                        mode="default"
                        @change="ecuNameChange"
                      >
                        <a-select-option v-for="item in ecuOptionArr" :key="item.ecuModuleId">{{ item.name}}|{{item.softwareCode }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- 零部件编号 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item prop="partNo">
                  <span slot="label">
                    <span class="requiredStar">*</span>
                    {{ $t('partNo') }}
                  </span>
                  <a-input :disabled="onlineDifference" :placeholder="$t('pleaseInput')+$t('partNo')" v-model="formData.partNo" :max-length="500"/>
                </a-form-model-item>
              </a-col>
                <!-- 主芯片 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item prop="mainChip">
                       <span slot="label">
                        <span class="requiredStar">*</span>
                        {{ $t('mainChip') }}
                      </span>
                      <a-input :disabled="onlineDifference" :placeholder="$t('mainChipFormat')"
                        v-model="formData.mainChip" :max-length="100"/>
                    </a-form-model-item>
              </a-col>
              <!-- 是否为配置文件 -->
             <a-col :md="8" :sm="24">
                    <a-form-model-item>
                       <span slot="label">
                         <span class="requiredStar">*</span>
                          {{ $t('isConfigFile') }}
                       </span>
                      <a-select v-model="formData.isConfigFile" :disabled="onlineDifference" @change="showComfirm">
                        <a-select-option
                          v-for="(item,index) in yesOrNoEnumArr"
                          :key="index"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
               <!-- 工程院项目主管 -->
              <!-- <a-col :md="8" :sm="24" v-if="!isContactPersonId"> -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item prop="contactPersonId">
                       <template slot="label">
                          <span class="requiredStar">*</span>
                          {{ $t('engineerAcademySupervisor') }}
                        </template>
                       <a-select
                        :placeholder="$t('pleaseSelect')+$t('engineerAcademySupervisor')"
                        v-model="formData.contactPersonId"
                        showSearch
                        @change="handleEngineerSupervisorChange"
                        :filterOption="$commonFun.filterOption"
                      >
                        <a-select-option
                          v-for="item in engineerSupervisorList"
                          :key="item.id"
                        >{{ item.name}}-{{item.account}}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
                <!-- 车型子项目 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item>
                      <span slot="label">
                      {{ $t('vehicleSub') }}
                    </span>
                      <a-input
                        v-model="formData.subType" :disabled="onlineDifference" :maxLength="50" :placeholder="$t('pleaseInput')+$t('vehicleSub')"/>
                    </a-form-model-item>
              </a-col>
                   <!-- 软件编码 -->
              <a-col :md="8" :sm="24" v-if="isUpdateFile">
                    <a-form-model-item prop="softwareCode">
                       <span slot="label">
                          <span class="requiredStar">*</span>
                          {{ $t('softwareCoding') }}
                        </span>
                      <a-select
                        :disabled="!formData.ecuId||onlineDifference"
                        :placeholder="formData.ecuId ? $t('pleaseSelect') + $t('softwareCoding') : $t('firstSelectEcu')"
                        v-model="formData.softwareCode"
                        @change="softwareCodeChange"
                      >
                        <a-select-option
                          v-for="item in filterEcuList"
                          :key="item.softwareCode"
                        >{{ item.softwareCode }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- 配置文件软件编码 -->
              <a-col :md="8" :sm="24" v-else>
                    <a-form-model-item prop="softwareCode">
                      <span slot="label">
                          <span class="requiredStar">*</span>
                          {{ $t('configurationFileCode') }}
                        </span>
                      <a-select
                         allow-clear
                        :disabled="!formData.ecuId||onlineDifference"
                        :placeholder="formData.ecuId ? $t('pleaseSelect') + $t('configurationFileCode') : $t('firstSelectEcu')"
                        v-model="formData.softwareCode"
                         @change="softwareCodeChange"
                      >
                        <a-select-option
                          v-for="item in filterEcuList"
                          :key="item.configSoftwareCode"
                          :value="item.configSoftwareCode"
                        >{{ item.configSoftwareCode }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
                   <!-- 规划院项目主管 -->
              <!-- <a-col :md="8" :sm="24" v-if="!isContactPersonId"> -->
              <a-col :md="8" :sm="24" >
                    <a-form-model-item prop="creatorId">
                      <template slot="label">
                          <span class="requiredStar">*</span>
                          {{ $t('planningAcademySupervisor') }}
                        </template>
                       <a-select
                        v-model="formData.creatorId"
                        :placeholder="$t('pleaseSelect')+$t('planningAcademySupervisor')"
                        showSearch
                        @change="handleCreatorChange"
                         :filterOption="$commonFun.filterOption"
                      >
                        <a-select-option
                          showSearch
                          :filterOption="$commonFun.filterOption"
                          v-for="item in planningSupervisorList"
                          :key="item.id"
                        >{{ item.name }}-{{item.account}}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
            </a-row>
            <a-row style="margin-top:30px" :gutter="[36,10]">
               <!-- 硬件版本号 -->
              <a-col :md="8" :sm="24" v-if="isUpdateFile">
                    <a-form-model-item prop="hardVersion">
                      <span slot="label">
                          <span class="requiredStar">*</span>
                          {{ $t('hardVersion') }}
                        </span>
                      <a-input :placeholder="$t('pleaseInput')+$t('hardVersion')" v-model="formData.hardVersion" :maxLength="60" />
                    </a-form-model-item>
              </a-col>
               <!-- 版本号 -->
              <a-col :md="8" :sm="24" style="padding:4px 18px">
                  <div class="myLabel">
                      <span>
                        <span class="requiredStar">*</span>
                           {{ $t('softVersionName')}}
                        </span>
                      <question-mark-tip :tip-title="$t('inputVersionNameWithoutVTip')" :popupContainer="getPopupContainer">
                      </question-mark-tip>
                    </div>
                    <a-form-model-item prop="versionNumber">
                      <a-input
                        :disabled="onlineDifference"
                        :placeholder="$t('pleaseInput')+$t('softVersionName')"
                        v-model="formData.versionNumber" :max-length="50"
                      />
                    </a-form-model-item>
              </a-col>
              <!-- 升级包类型 -->
              <a-col :md="8" :sm="24" v-if="isUpdateFile">
                    <a-form-model-item prop="upgradePackType">
                      <span slot="label">
                          <span class="requiredStar">*</span>
                          {{ $t('sjblx') }}
                        </span>
                      <a-select :placeholder="$t('pleaseSelect')+$t('sjblx')" v-model="formData.upgradePackType" :disabled="!formData.versionNumber||onlineDifference" @change="updateFileType">
                        <a-select-option
                          v-for="item in updateFileTypeEnumArr"
                          :key="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- 硬件版本日期 -->
              <a-col :md="8" :sm="24" v-if="isUpdateFile">
                    <a-form-model-item prop="hardVersionDate">
                      <span slot="label">
                          <span class="requiredStar">*</span>
                          {{ $t('hardVersionDate') }}
                        </span>
                      <a-date-picker
                        :placeholder="$t('timeSelectPlaceholder')"
                        v-model="formData.hardVersionDate"
                        format="YYYY-MM-DD"
                        :disabledDate="disabledEndDate"
                        :popupContainer="$commonFun.getPopupContainer"
                        @change="onChangeDate"
                        style="width:100%"
                      />
                    </a-form-model-item>
              </a-col>
                 <!-- 软件日期 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item prop="proDate">
                       <span slot="label">
                         <span class="requiredStar">*</span>
                          {{ $t('softwareDate') }}
                       </span>
                      <a-date-picker
                        :placeholder="$t('timeSelectPlaceholder')"
                        v-model="formData.proDate"
                        format="YYYY-MM-DD"
                        :disabledDate="disabledEndDate"
                        :popupContainer="$commonFun.getPopupContainer"
                        @change="onChangesoftwareDate"
                        style="width:100%"
                      />
                    </a-form-model-item>
              </a-col>
                   <!-- DLL文件类名 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item prop="dllName">
                  <template slot="label">
                      <span class="requiredStar">*</span>
                      {{ $t('dllFileClassName') }}
                  </template>
                  <a-select :placeholder="$t('dllPlaceholder')" @change="changeDllName" v-model="formData.dllName" showSearch  :filterOption="$commonFun.filterOption">
                    <a-select-option
                      v-for="item in dllNameArr"
                      :key="item.code"
                    >{{ item.name }}</a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <!-- boot版本 -->
              <a-col :md="8" :sm="24" v-if="isUpdateFile" style="padding:3px 18px">
                <a-form-model-item prop="bootVer">
                  <template slot="label">
                    <span class="requiredStar">*</span>
                    {{ $t('bootVersion') }}
                  </template>
                  <a-input :placeholder="$t('pleaseInput')+$t('bootVersion')" v-model="formData.bootVer" :max-length="500"/>
                </a-form-model-item>
              </a-col>
               <!-- 兼容版本 -->
              <a-col :md="8" :sm="24" style="padding:4px 18px">
                 <div class="myLabel">
                      <span>
                        <span class="requiredStar">*</span>
                           {{ $t('dependencyVersion')}}
                        </span>
                      <question-mark-tip :tip-title="$t('dependencyVersionTipOfMC')" :popupContainer="getPopupContainer">
                      </question-mark-tip>
                    </div>
                <a-form-model-item prop="compatibleVersion">
                      <a-select
                        :disabled="!formData.softwareCode||disablePackage"
                        mode="tags"
                        style="width: 100%"
                        v-model="formData.compatibleVersion"
                        @focus="beforeEditRecordData('compatibleVersion')"
                        :placeholder="$t('compatibleVersionFormat')"
                        @change="check"
                      >
                        <a-select-option v-for="item in verisonList" :key="item">{{ item }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- 烧写类型 -->
              <a-col :md="8" :sm="24">
                <div class="myLabel">
                  <span>
                    <span class="requiredStar">*</span>
                        {{ $t('sxType')}}
                    </span>
                  <question-mark-tip :tip-title="'烧写类型VDS（CAN/CANFD）、VDS（以太网）默认支持OTA升级。'" :popupContainer="getPopupContainer">
                  </question-mark-tip>
                </div>
                <a-form-model-item prop="ecuReprogramType">
                  <a-select
                    v-model="formData.ecuReprogramType"
                    :disabled="disableFlushBtn"
                    :placeholder="$t('pleaseSelect')+$t('sxType')"
                      @change="changeReprogramType">
                  >
                    <a-select-option
                      v-for="item in flushTypeEnumArr2"
                      :key="item.code"
                    >{{ item.name }}</a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <!-- 超时时间 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item prop="timeout">
                  <template slot="label">
                    <span class="requiredStar">*</span>
                    {{ $t('timeoutPeriod') }}
                  </template>
                  <a-input-number :placeholder="$t('pleaseInput')+$t('timeoutPeriod')+'，'+$t('timeoutPeriodDefault')" style="width:100%"  :precision="0" v-model="formData.timeout" />
                </a-form-model-item>
              </a-col>
              <!-- 烧写规范 -->
              <a-col :md="16" :sm="24" style="margin-top:10px;">
                <a-form-model-item prop="criterion">
                    <template slot="label">
                      <span class="requiredStar">*</span>
                      {{ $t('burnSpecification') }}
                    </template>
                  <a-textarea :rows="7" v-model="formData.criterion" :max-length="500" :placeholder="burnSpecificationTip"/>
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row style="margin-top:30px" :gutter="36">
              <!-- 产品安全/环保/节能/防盗等技术性能变化 -->
              <a-col :md="8" :sm="24" >
                    <a-form-model-item prop="technicalFeature">
                      <template slot="label">
                      <span class="requiredStar">*</span>
                      {{ $t('technicalPerformanceChange') }}
                    </template>
                      <a-select v-model="formData.technicalFeature"
                      @change="(event)=>{if(!event){$set(formData,'notice',undefined);$set(formData,'technicalParameters','');verifyList = [];verifyInfoList=[];}}"
                      placeholder="是/否">
                        <a-select-option
                          v-for="(item,index) in yesOrNoEnumArr"
                          :key="index"
                          :value="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- 是否涉及公告技术参数变更 -->
              <a-col :md="8" :sm="24" :style="{'opacity' : formData.technicalFeature ? '1' : '0.3'}">
                  <a-form-model-item prop="notice">
                    <template slot="label">
                      <span class="requiredStar">*</span>
                      {{ $t('isTechnicalParameterChange') }}
                    </template>
                      <a-select v-model="formData.notice" :disabled="!formData.technicalFeature" placeholder="是/否" @change="(event)=>{if(!event){formData.technicalParameters = '';verifyList = [];verifyInfoList=[];}}">
                        <a-select-option
                          v-for="(item,index) in yesOrNoEnumArr"
                          :key="index"
                          :value="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
            </a-row>
            <a-row :gutter="36">
              <!-- 上传验证材料 -->
              <a-col :md="8" :sm="24" :style="{'opacity' : formData.notice&&formData.technicalFeature ? '1' : '0.3'}">
                <a-form-model-item>
                  <template slot="label">
                    {{ $t('uploadVerificationMaterials') }}
                  </template>
                </a-form-model-item>
                <a-card class="card" title="附件信息" size="small" style="border-radius:10px"
                        :headStyle="{background: 'rgb(184 186 207)', 'min-height': '30px', 'border-radius': '10px 10px 0 0'}"
                        :bodyStyle="{'height': '118px', 'overflow': 'auto', 'margin-top': '1px'}"

                >
                  <div slot="extra" style="">
                    <a-upload :showUploadList="false" :multiple="true" :file-list="verifyList"
                              :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_verify')">
                      <a-button :loading="uploading1" size="small" style="border:1px solid #147092;color:#147092"
                                :disabled="!formData.notice || !formData.technicalFeature">
                        <a-icon type="plus-circle" theme="filled" v-if="!uploading1" />
                        {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                  </div>
                  <p class="mr8" v-for="(item, index) in verifyInfoList" :key="index"
                     style="border-bottom: 1px solid #ccc; height: 30px; line-height: 30px;">
                    <a @click="downloadFile(item)" style="display: inline-block;width: calc(100% - 50px);"
                       :disabled="!formData.notice || !formData.technicalFeature">
                      <table-ellipsis :title="item.fileName" :text="item.fileName" :tableEllipsisIsTurnLine="false"/>
                    </a>
                    <a @click="(item) => {verifyInfoList.splice(index, 1);verifyList.splice(index, 1)}"
                       style="color:red;float:right;" :disabled="!formData.notice || !formData.technicalFeature">
                      {{$t('delete')}}
                    </a>
                  </p>
                  <br/>
                </a-card>
              </a-col>
               <!-- 《公告》技术参数变更 -->
              <a-col :md="16" :sm="24" :style="{'opacity' :formData.notice&&formData.technicalFeature ? '1' : '0.3'}">
                    <a-form-model-item prop="technicalParameters">
                       <template slot="label">
                      <span class="requiredStar">*</span>
                      {{ $t('technicalParameterChange') }}
                    </template>
                      <a-textarea :rows="7" v-model="formData.technicalParameters"
                      :disabled="!formData.notice||!formData.technicalFeature" :max-length="2000" style="marginTop:10px"
                      :placeholder="$t('pleaseInput')+$t('technicalParameterChange')+'说明...'"/>
                    </a-form-model-item>
              </a-col>
            </a-row>
            <a-row style="margin-top:30px" :gutter="36">
              <!-- 是否涉及海外法规文件 -->
              <a-col :md="8" :sm="24">
                <a-row>
                  <a-col>
                    <a-form-model-item prop="overLawsChange">
                      <template #label>
                        <span class="requiredStar">*</span>
                        {{ $t('isOverseasRegulatoryInvolve') }}
                      </template>
                      <a-select v-model="formData.overLawsChange" placeholder="是/否" @change="(event)=>{if(!event){$set(formData,'overParameters',undefined);overSeasList = [];overSeasInfoList = []}}">
                        <a-select-option
                          v-for="(item,index) in yesOrNoEnumArr"
                          :value="item.value"
                          :key="index"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
                  </a-col>
                  <!-- 影响海外法规参数 -->
                  <a-col  :style="{'opacity' : formData.overLawsChange ? '1' : '0.3'}">
                    <a-form-model-item prop="overParameters">
                      <template #label>
                        <span class="requiredStar">*</span>
                        {{ $t('influenceOverseasRegulatoryParams') }}
                      </template>
                      <a-select v-model="formData.overParameters" placeholder="是/否" :disabled="!formData.overLawsChange" @change="(event)=>{if(!(event=='1')){overSeasList = [];overSeasInfoList = []}}">
                        <a-select-option
                          v-for="(item,index) in yesOrNoEnumArrString"
                          :key="index"
                          :value="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
                </a-row>
              </a-col>

              <!-- 上传海外法规验证材料 -->
              <a-col :md="8" :sm="24" :style="{'opacity' : formData.overParameters=='1'&&formData.overLawsChange ? '1' : '0.3'}" >
                    <a-form-model-item>
                      <template slot="label">
                        {{ $t('uploadOverseasVerificationMaterials') }}
                      </template>
                    </a-form-model-item>
                      <a-card class="card" title="附件信息" size="small" style="border-radius:10px"
                         :headStyle="{background: 'rgb(184 186 207)', 'min-height': '30px', 'border-radius': '10px 10px 0 0'}"
                        :bodyStyle="{'height': '118px', 'overflow': 'auto', 'margin-top': '1px'}"

                      >
                        <div slot="extra" style="">
                          <a-upload  :showUploadList="false"  :multiple="true" :file-list="overSeasList"    :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_over_verify')">
                             <a-button :loading="uploading2" size="small" style="border:1px solid #147092;color:#147092"
                                :disabled="!formData.overParameters=='1' || !formData.overLawsChange">
                        <a-icon type="plus-circle" theme="filled" v-if="!uploading2" />
                        {{ $t('uploadAttachment') }}
                        </a-button>
                      </a-upload>
                    </div>
                     <p class="mr8" v-for="(item, index) in overSeasInfoList" :key="index"
                     style="border-bottom: 1px solid #ccc; height: 30px; line-height: 30px;">
                    <a @click="downloadFile(item)" style="display: inline-block;width: calc(100% - 50px);"
                       :disabled="!formData.overParameters=='1' || !formData.overLawsChange">
                      <table-ellipsis :title="item.fileName" :text="item.fileName" :tableEllipsisIsTurnLine="false"/>
                    </a>
                    <a @click="(item) => {overSeasInfoList.splice(index, 1);overSeasList.splice(index, 1)}"
                       style="color:red;float:right;" :disabled="!formData.overParameters=='1' || !formData.overLawsChange">
                      {{$t('delete')}}
                    </a>
                  </p>
                  <br/>
                </a-card>
              </a-col>
            </a-row>
          </a-form-model-item>
        </a-card>
        <!-- 软件用途 -->
        <a-card class="card-radius" id="sw-step-2">
          <!-- <p id="2" class="customFormModelItem2">{{ $t('softwareUse') }}</p> -->
            <a-row :gutter="36">
              <a-col :md="8" :sm="24">
            <a-form-model-item>
              <span slot="label">
              <span class="requiredStar">*</span>
              {{ $t('softwareUse') }}
             </span>
              <div style="border:1px solid #ccc;padding:10px 20px;border-radius:10px">
                  <!-- 供应商选项-->
                  <a-form-model-item prop="softPurposeSupplier">
                      <span slot="label">
                        <span class="requiredStar">*</span>
                        {{ $t('supplierOption') }}
                      </span>
                      <a-select v-model="formData.softPurposeSupplier" @change="changeSoftwareUse" :placeholder="$t('pleaseSelect')+'供应商软件用途'">
                        <a-select-option
                          v-for="item in softwareUseEnumArr"
                          :key="item.code"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                  </a-form-model-item>
                  <!-- 工程师选项 -->
                  <a-form-model-item prop="softPurpose">
                      <span slot="label">
                        <span class="requiredStar">*</span>
                        {{ $t('engineerOption') }}
                      </span>
                      <a-select v-model="formData.softPurpose" :placeholder="$t('pleaseSelect')+'工程师软件用途'">
                        <a-select-option
                          v-for="item in softUseEngineer"
                          :key="item.code"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
                  <!-- 软件发布范围 -->
                    <a-form-model-item prop="softStageDetailSupplier" :style="{'opacity' : formData.softPurposeSupplier=='SOFTWARE_RELEASE' ? '1' : '0.3'}" >
                      <span slot="label">
                        <span class="requiredStar">*</span>
                        {{ $t('softwareDistributionScope') }}
                      </span>
                      <a-select v-model="formData.softStageDetailSupplier" :placeholder="$t('pleaseSelect')+$t('softwareDistributionScope')" :disabled="formData.softPurposeSupplier!='SOFTWARE_RELEASE'">
                        <a-select-option
                          v-for="item in softwareDistributionScopeEnumArr"
                          :key="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </div>
          </a-form-model-item>
       </a-col>
              <!-- 车型开发阶段 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item prop="carDevStage">
                      <span slot="label">
                        <span class="requiredStar">*</span>
                        {{ $t('modelDevelopmentStage') }}
                      </span>
                      <a-select v-model="formData.carDevStage" :placeholder="$t('pleaseSelect')+$t('modelDevelopmentStage')">
                        <a-select-option
                          v-for="item in carDevStageArr"
                          :key="item.code"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
                    <!-- 用户感知 -->
                <a-form-model-item prop="perceptible">
                  <span slot="label">
                    <span class="requiredStar">*</span>
                    {{ $t('userPerception') }}
                  </span>
                  <a-select v-model="formData.perceptible" :placeholder="$t('pleaseSelect')+$t('userPerception')">
                    <a-select-option
                      v-for="item in userPerceptionEnumArr"
                      :key="item.value"
                    >{{ item.name }}</a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
               <!-- ECN/ECR/DCN文档上传 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item>
                  <template slot="label">
                    <span v-if="formData.carDevStage=='SOP'" class="requiredStar">*</span>
                    {{ $t('ecnEcrDcnFileDocumentUpload') }}
                  </template>
                </a-form-model-item>
                   <a-card class="card" title="附件信息" size="small" style="border-radius:10px"
                        :headStyle="{background: 'rgb(184 186 207)', 'min-height': '30px', 'border-radius': '10px 10px 0 0'}"
                        :bodyStyle="{'height': '118px', 'overflow': 'auto', 'margin-top': '1px'}"
                >
                  <div slot="extra" style="">
                    <a-upload :showUploadList="false" :multiple="true" :file-list="ECNList"
                              :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_ecn_ecr')">
                      <a-button :loading="uploading3" size="small" style="border:1px solid #147092;color:#147092"
                                >
                        <a-icon type="plus-circle" theme="filled" v-if="!uploading3" />
                        {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                  </div>
                  <p class="mr8" v-for="(item, index) in ECNInfoList" :key="index"
                     style="border-bottom: 1px solid #ccc; height: 30px; line-height: 30px;">
                    <a @click="downloadFile(item)" style="display: inline-block;width: calc(100% - 50px);"
                       >
                      <table-ellipsis :title="item.fileName" :text="item.fileName" :tableEllipsisIsTurnLine="false"/>
                    </a>
                    <a @click="(item) => {ECNInfoList.splice(index, 1);ECNList.splice(index, 1)}"
                       style="color:red;float:right;" >
                      {{$t('delete')}}
                    </a>
                  </p>
                  <br/>
                </a-card>
              </a-col>
            </a-row>
            <a-row :gutter="36" style="margin-top:30px">
              <!-- 状态总结 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item prop="stateSum">
                  <span slot="label">
                    <span class="requiredStar">*</span>
                    {{ $t('stateSummary') }}
                  </span>
                  <a-select v-model="formData.stateSum" @change="handleStateSum" :placeholder="$t('pleaseSelect')+'软件状态'">
                    <a-select-option
                        v-for="item in stateSummaryEnumArr"
                        :key="item.value"
                    >{{ item.name }}</a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <!-- 紧急程度 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item prop="isEmergency">
                       <span slot="label">
                        <span class="requiredStar">*</span>
                        {{ $t('degreeOfUrgency') }}
                      </span>
                      <a-select v-model="formData.isEmergency" :placeholder="$t('pleaseSelect')+$t('degreeOfUrgency')" 
                        @change="(event)=>{if(!event){formData.emergencyReason = '';$refs['newEditForm'].clearValidate(['emergencyReason'])}}">
                        <a-select-option
                          v-for="item in degreeOfUrgencyEnumArr"
                          :key="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
                 <!-- 是否影响认证或准入或法规要求 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item prop="impressApprove">
                       <span slot="label">
                         <span class="requiredStar">*</span>
                      {{ $t('isAffectsCertificationOrRegulatory') }}
                      </span>
                      <a-select v-model="formData.impressApprove" placeholder="是/否" 
                        @change="(event)=>{if(!event){formData.impressCarType = '';$refs['newEditForm'].clearValidate(['impressCarType'])}}">
                        <a-select-option
                          v-for="(item,index) in yesOrNoEnumArr"
                          :key="index"
                          :value="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- 问题总结 -->
              <a-col :md="8" :sm="24" >
                    <a-form-model-item prop="problemsSum">
                      <span slot="label">
                        <span v-if="!isPass" class="requiredStar">*</span>
                        {{ $t('problemSummary') }}
                      </span>
                      <a-textarea :rows="7" v-model="formData.problemsSum" placeholder="请填入问题总结" :max-length="200" style="marginTop:10px"/>
                    </a-form-model-item>
              </a-col>
              <!-- 紧急原因 -->
              <a-col :md="8" :sm="24" :style="{'opacity' :formData.isEmergency ? '1' : '0.3'}">
                  <a-form-model-item prop="emergencyReason">
                    <span slot="label">
                      <span class="requiredStar">*</span>
                      {{ $t('urgentCause') }}
                    </span>
                      <a-textarea :rows="7" style="marginTop:10px" :disabled="!formData.isEmergency"
                        v-model="formData.emergencyReason" placeholder="请填写紧急原因..." :max-length="500"
                      />
                  </a-form-model-item>
              </a-col>
                <!-- 影响项目或参数 -->
              <a-col :md="8" :sm="24"  :style="{'opacity' :formData.impressApprove ? '1' : '0.3'}">
                    <a-form-model-item prop="impressCarType">
                       <span slot="label">
                         <span class="requiredStar">*</span>
                      {{ $t('effectsItemsOrParameters') }}
                      </span>
                      <a-textarea :rows="7" style="marginTop:10px" :disabled="!formData.impressApprove"
                       v-model="formData.impressCarType" :max-length="500" placeholder="请填写影响项目或参数说明..."/>
                    </a-form-model-item>
              </a-col>
              <!-- 软件变更说明 -->
              <a-col :md="24" :sm="24" style="margin-top:10px;">
                    <a-form-model-item>
                    <div class="myLabel" >
                      <span>
                        <span class="requiredStar">*</span>
                           {{ $t('softwareChangeDescription')}}
                        </span>
                        <span style="marginBottom:5px">
                       <a-button style="margin-right:10px; border:1px solid #147092;color:#147092" @click="addChangeExplains">
                      <a-icon type="plus-circle" theme="filled" />
                        {{$t('plus')}}
                      </a-button>
                      <a-upload
                        name="file"
                        :multiple="false"
                        :showUploadList="false"
                        accept=".xlsx, .xls"
                        :before-upload="beforeFileUpload"
                        :customRequest="fileUpload"
                      >
                        <a-button style="margin-right:10px; border:1px solid #147092;color:#147092">
                          <a-icon type="export" style=" color: rgb(20, 112, 146);"/>
                            {{$t('importAttachment')}}
                        </a-button>
                      </a-upload>
                      <a-button
                        @click="downloadTempFile" style="margin-right:10px; border:1px solid #147092;color:#147092"
                          ><a-icon type="download"/>{{ $t('downloadTemplate') }}
                      </a-button>
                      <a-button style="border:1px solid red;color:red" @click="deleteAllChangeExplains">
                        <a-icon type="close-circle" theme="filled" style="color:red"/>
                        {{$t('deleteAll')}}
                      </a-button>
                        </span>
                    </div>
                      <a-table
                        :columns="softwareChangeColumns"
                        :data-source="formData.changeExplains"
                        :rowKey="(record, index) => {return index}"
                        :pagination="false"
                        style="margin-top:10px;min-height:200px"
                      >
                        <!-- :scroll="{x:1200,y:200}" -->
                       <!-- 变更前 -->
                      <template slot="beforeChange" slot-scope="text,record,index">
                        <a-form-model-item
                        :prop="'changeExplains.'+index+'.changeBefore'"
                        :rules="rules.changeBefore">
                          <a-input v-model="record.changeBefore" :max-length="1000"></a-input>
                        </a-form-model-item>
                      </template>
                       <!-- 变更后 -->
                      <template slot="afterChange" slot-scope="text,record,index">
                        <a-form-model-item
                        :prop="'changeExplains.'+index+'.inflectContent'"
                        :rules="rules.inflectContent">
                          <a-input  v-model="record.inflectContent" :max-length="1000"></a-input>
                        </a-form-model-item>
                      </template>
                       <!-- 功能原理 -->
                      <template slot="functionalPrinciple" slot-scope="text,record,index">
                        <a-form-model-item
                        :prop="'changeExplains.'+index+'.function'"
                        :rules="rules.function">
                          <a-input v-model="record.function" :max-length="1000"></a-input>
                        </a-form-model-item>
                      </template>
                       <!-- 造成影响 -->
                      <template slot="influence" slot-scope="text,record,index">
                        <a-form-model-item
                        :prop="'changeExplains.'+index+'.affect'"
                        :rules="rules.affect">
                          <a-input  v-model="record.affect" :max-length="1000"></a-input>
                        </a-form-model-item>
                      </template>
                       <!-- 变更目的 -->
                      <template slot="changeOfPurpose" slot-scope="text,record,index">
                        <a-form-model-item
                        :prop="'changeExplains.'+index+'.purpose'"
                        :rules="rules.purpose">
                          <a-input  v-model="record.purpose" :max-length="1000"></a-input>
                        </a-form-model-item>
                      </template>
                       <!-- 变更属性 -->
                      <template slot="changeAttribute" slot-scope="text,record,index">
                        <a-form-model-item
                        :prop="'changeExplains.'+index+'.property'"
                        :rules="rules.property">
                          <a-select
                            v-model="record.property"
                            @change="(val)=>handleAttributeChange(val,record,index)"
                            :popupContainer="getPopupContainer"
                            :placeholder="$t('pleaseSelect') + $t('changeAttribute')"
                          >
                            <a-select-option
                              v-for="item in changeAttributeEnumArr"
                              :key="item.name"

                            >{{ item.name}}</a-select-option>
                          </a-select>
                      </a-form-model-item>
                      </template>
                       <!-- 问题等级 -->
                      <template slot="problemLevel" slot-scope="text,record,index">
                        <a-form-model-item
                        :prop="'changeExplains.'+index+'.questionLevel'"
                        :rules="record.property==''||record.property=='功能新增'||record.property=='首次导入'?{}:rules.questionLevel">
                          <a-select
                            v-model="record.questionLevel"
                            :popupContainer="getPopupContainer"
                            :placeholder="$t('pleaseSelect') + $t('problemLevel')"
                          >
                            <a-select-option
                              v-for="item in problemLevelEnumArr"
                              :key="item.name"

                            >{{ item.name}}</a-select-option>
                          </a-select>
                        </a-form-model-item>
                      </template>
                       <!-- 操作 -->
                      <template slot="operation" slot-scope="text,record,index">
                        <a-button @click="deleteChangeExplains(text,record,index)">
                          {{$t('delete')}}
                        </a-button>
                      </template>
                      </a-table>

                    </a-form-model-item>
              </a-col>
            </a-row>
        </a-card>
        <!-- 文件信息 -->
        <a-card class="card-radius" id="sw-step-3">
          <a-row class="customFormModelItem2" style="marginRight:3%">
            <a-col :span="12"><span class="requiredStar">*</span>{{ $t('fileInfo') }}</a-col>
            <a-col :span="12" style="text-align: right" v-if="isUpdateFile&&!onlineDifference">
              <auth-button @click="handleAddFile" :disabled="disableUpload"><a-icon type="plus-circle" theme="filled"/>{{ $t('uploadFile') }}</auth-button>
            </a-col>
            <a-col :span="12" style="text-align: right" v-if="onlineDifference">
              <auth-button @click="handleOnlineDiff" :disabled="disableUpload"><a-icon type="plus-circle" theme="filled"/>{{ $t('onlineDifference') }}</auth-button>
            </a-col>
          </a-row>
          <a-form-model-item v-if="isUpdateFile&&!onlineDifference">
            <a-table
              :columns="columns"
              :data-source="fileList"
              rowKey="fileId"
              :pagination="false"
              :scroll="{y:200}"
              style="min-height:200px"
            >
              <template #primitiveVersion="text">{{ text?text:'-' }}</template>
              <template #checksum="text">
                <a @click="viewCheckSum(text)">{{ $t('view') }}</a>
              </template>
              <template
                #hashAlgorithm="text"
              >{{ $options.filters.DictLabelFilter(text,digestAlgorithmEnum) }}</template>
              <template
                #fileReprogramType="text"
              >{{ text }}</template>
              <template #operation="text,record,index">
                <span class="set-margin">
                  <a-icon type="edit" />
                  <a @click="handleEditFileInfo(text,record,index)">{{ $t('edit') }}</a>
                </span>
                <span>
                  <i class="iconfont icon-shanchu deleteUlr"></i>
                  <a @click="handleDeleteFile(text,record,index)">{{ $t('delete') }}</a>
                </span>
              </template>
            </a-table>
          </a-form-model-item>
          <a-form-model-item v-else-if="!isUpdateFile&&!onlineDifference">
            <div style="border:1px solid #ccc;padding:20px 20px;border-radius:10px">
              <a-row :gutter="36">
              <!-- 摘要算法 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item>
                      <span slot="label">
                         <span class="requiredStar">*</span>
                      {{ $t('zysf') }}
                      </span>
                      <a-select
                        v-model="formData.upgradePacks[0].hashAlgorithm"
                        @change="handleConfigHashAlgorithmChange"
                        :placeholder="$t('pleaseSelect')+$t('zysf')"
                      >
                        <a-select-option
                          v-for="(key,val,index) in digestAlgorithm"
                          :key="index"
                          :value="parseInt(val,10)"
                        >{{ key }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
              </a-col>
              <!-- 摘要值 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item>
                  <div class="myLabel">
                  <span>
                    <span class="requiredStar">*</span>
                        {{ $t('zyz')}}
                    </span>
                    <div>
                      <a-switch style="marginRight:8px;marginBottom:8px;" :default-checked="isManualEntry" @change="handleManuallyInputSum" />
                      <span style="font-weight: normal">{{ $t('manualInput') }}</span>
                    </div>
                </div>
                  <a-input v-model="formData.upgradePacks[0].checksum" :placeholder="$t('pleaseInput')+$t('zyz')" v-if="isManualEntry"/>
                  <a-input :disabled="true" :placeholder="$t('pleaseInput')+$t('zyz')" v-model="configFile.fileObject[digestAlgorithm[formData.upgradePacks[0].hashAlgorithm]]" v-else/>
                </a-form-model-item>
              </a-col>
            </a-row>
              <a-row :gutter="36">
                <!-- 预计安装时间 -->
              <a-col :md="8" :sm="24">
                <div class="myLabel">
                  <span>
                    <span class="requiredStar">*</span>
                        {{ $t('estimatedInstallTime')}}
                    </span>
                    <span>s</span>
                </div>
                <a-form-model-item prop="upgradePacks[0].installSec">
                  <a-input-number style="width:100%" :min="1" :max="2147483647" v-model="formData.upgradePacks[0].installSec" :placeholder="$t('pleaseInput')+$t('estimatedInstallTime')" />
                </a-form-model-item>
              </a-col>
              <!-- 配置文件 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item>
                      <span slot="label">
                         <span class="requiredStar">*</span>
                          {{ $t('configFile') }}
                      </span>
                      <a-input
                        ref="userNameInput"
                        readOnly
                        :placeholder="$t('pleaseUpload')"
                        v-model="formData.upgradePacks[0].fileName"
                      >
                        <a-icon @click="uploadConfigFile" slot="suffix" type="upload" />
                      </a-input>
                      <chunk-upload
                        ref="uploadConfigFile"
                        @uploadDone="handleUploadDone"
                        @uploadStart="handleUploadStart"
                        :showDom="false"
                        fileStoreField="fileObject"
                        :recordData="configFile"
                        uploadType="8"
                        :userPartUrl="true"
                        :size="5*1024*1024*1024"
                        :hashAlgorithm="formData.upgradePacks[0].hashAlgorithm"
                      >
                      </chunk-upload>
                    </a-form-model-item>
              </a-col>
                </a-row>
                  <!-- 文件烧写类型 -->
                <!-- <a-row :gutter="36">
                  <a-col :md="8" :sm="24">
                    <a-form-model-item prop="upgradePacks[0].fileReprogramType">
                      <span slot="label">
                        <span class="requiredStar">*</span>
                          {{ $t('file')+$t('sxType') }}
                      </span>
                      <a-select v-model="formData.upgradePacks[0].fileReprogramType"
                          :placeholder="$t('pleaseSelect')+$t('file')+$t('sxType')">
                        <a-select-option
                          v-for="item in fileFlushTypeEnumArr"
                          :key="item.value"
                        >{{ item.name }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
                  </a-col>
                </a-row> -->
            </div>
            <p class="customFormModelItem2" style="margin-top:20px"><span class="requiredStar">*</span>{{ $t('zcxxx') }}</p>
            <div style="border:1px solid #ccc;padding:20px 20px;border-radius:10px">
              <a-row
                class="customFormModelItem2"
                >
                <a-col :span="4">
                  <!-- <a-row>
                    <a-col :md="6" :sm="24" style="textAlign:right">
                      <a-form-model-item>{{ $t('formsId') }}</a-form-model-item>
                    </a-col>
                    <a-col :md="18" :sm="24"> -->
                      <a-form-model-item>
                        <span slot="label">
                          {{ $t('formsId') }}
                          </span>
                        <a-input
                          placeholder="请输入表单编号关键字检索"
                          v-model="searchRelatedFormName"
                          style="width: 100%"
                          @keyup.enter="handleSearchForm"
                          :max-length="50"
                        />
                      </a-form-model-item>
                    <!-- </a-col>
                  </a-row> -->
                </a-col>
                <a-col :span="8" style="margin-top:22px;margin-left:8px;">
              <span style="display: flex;">
                <a-button-group style="margin-right:8px;">
                  <auth-button  @click="handleSearchForm"><i class="iconfont icon-chazhao"/>{{ $t('inquiry') }}</auth-button>
                  <auth-button :ghost="true" @click="handleClear"><i class="iconfont icon-qingkong"/>{{ $t('reset') }}</auth-button>
                </a-button-group>
                <auth-button style="border:1px solid #147092;color:#147092"  :ghost="true" @click="addChecked" ><a-icon type="plus-circle" theme="filled"/>添加选中</auth-button>
              </span>
                </a-col>
                <a-col  style="margin-top:22px;">
                <a-pagination
                :pageSizeOptions="['10', '20', '50']"
                :current="pageInfo.pageNo"
                :pageSize="pageInfo.pageSize"
                :total="pageInfo.totalCount"
                :totalPage="pageInfo.totalPage"
                :showSizeChanger="true"
                :showQuickJumper="true"
                :showTotal= "(total)=> '共'+total+'条'"
                @change="changePage"
                @showSizeChange="showSizeChange"
                style="display: flex;float:right;"
                />
                </a-col>
              </a-row>
              <a-form-model-item>
                <a-table
                  :columns="mainProgramTbColumns"
                  :data-source="dataFormTb"
                  :pagination="false"
                  rowKey="id"
                  :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
                  :scroll="{y:300}"
                  style="min-height:300px"
                >
                  <template slot="createTime" slot-scope="text">
                    <table-ellipsis
                      :tableEllipsisIsTurnLine="false"
                      :text="text ? $options.filters.moment(text) : '_'"
                    ></table-ellipsis>
                  </template>
                  <template #operation="text">
                    <span class="set-margin">
                      <a-icon type="edit" />
                      <a @click="clickRowOperation('edit',text)">{{ $t('edit') }}</a>
                    </span>
                    <span>
                      <i class="iconfont icon-shanchu deleteUlr"></i>
                      <a @click="clickRowOperation('delete',text)">{{ $t('delete') }}</a>
                    </span>
                  </template>
                </a-table>
                <!-- 已选中表单 -->
                  <b>
                    已选中表单
                  </b>
                <a-table
                  :columns="mainProgramTbColumnsSelected"
                  :data-source="dataSelected"
                  :pagination="false"
                  rowKey="id"
                  :scroll="{y:300}"
                  style="min-height:300px"
                >
                  <template slot="createTime" slot-scope="text">
                    <table-ellipsis
                      :tableEllipsisIsTurnLine="false"
                      :text="text ? $options.filters.moment(text) : '_'"
                    ></table-ellipsis>
                  </template>
                  <span slot="bulkDeletion">
                    <a-button type="danger" @click="bulkDeletion" :ghost="true" size="small"><i class="iconfont icon-shanchu deleteUlr"></i>清空选择</a-button>
                  </span>
                  <template #operation="text, record">
                    <a @click="deleteSelected(record)" style="color: red;" type="danger" :ghost="true" size="small">{{ $t('delete') }}</a>
                  </template>
                </a-table>
              </a-form-model-item>
            </div>
          </a-form-model-item>
          <!-- 在线差分展示 -->
          <a-form-model-item v-else>
             <a-table
              :columns="columns"
              :data-source="fileList"
              rowKey="fileId"
              :pagination="false"
              :scroll="{y:200}"
              style="min-height:200px"
            >
              <template #primitiveVersion="text">{{ text?text:'-' }}</template>
              <template #checksum="text">
                <a @click="viewCheckSum(text)">{{ $t('view') }}</a>
              </template>
              <template #fileSize="text">
                <span v-if="text">{{text}}</span>
                <span v-if="!text">-</span>
              </template>
              <template
                #hashAlgorithm="text"
              >{{ $options.filters.DictLabelFilter(text,digestAlgorithmEnum) }}</template>
              <template
                #fileReprogramType="text"
              >{{ text }}</template>
              <template #operation="text,record,index">
                <span>
                  <i class="iconfont icon-shanchu deleteUlr"></i>
                  <a @click="handleDeleteFile(text,record,index)">{{ $t('delete') }}</a>
                </span>
              </template>
            </a-table>
          </a-form-model-item>
        </a-card>
        <!-- 测试信息 -->
        <a-card class="card-radius" id="sw-step-4">
            <!-- <p>{{ $t('testInformation') }}</p> -->
          <a-form-model-item >
            <table class="testInfo"  cellspacing="0" cellpadding="0">
              <!-- 软件开发匹配测试计划 -->
              <tr>
                <td class="td1">
                  {{ $t('softwareMatchesPlans')+'：' }}
                </td>
                <td class="td2">
                  <span class="mr8 tag" v-for="(item, index) in testInfoList" :key="index">
                    <a @click="downloadFile(item)">{{item.fileName}}</a>
                    <i class="iconfont icon-shanchu3 deleteUlr" @click="handleRemove('vds_plan_delete',item.fileId, index)"/>
                  </span>
                </td>
                <td class="td3">
                    <a-upload :multiple="true" :showUploadList="false" :file-list="testPlanList"  :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_plan')">
                       <a-button class="mr8" style="border:1px solid #147092;color:#147092" :loading="uploading4"><a-icon type="plus-circle" theme="filled" v-if="!uploading4"  />
                       {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                </td>
              </tr>
              <!-- 软件需求分析说明书 -->
              <tr>
                <td class="td1">
                  {{ $t('softwareRequirementsAnalysis')+'：' }}
                </td>
                <td class="td2">
                  <span class="mr8 tag" v-for="(item, index) in demandInfoList" :key="index">
                      <a @click="downloadFile(item)">{{item.fileName}}</a>
                      <i class="iconfont icon-shanchu3 deleteUlr" @click="handleRemove('vds_demand_delete',item.fileId, index)"/>
                      </span>
                </td>
                <td class="td3">
                    <a-upload :multiple="true" :showUploadList="false" :file-list="demandList" :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_demand')">
                       <a-button class="mr8" style="border:1px solid #147092;color:#147092"  :loading="uploading5"><a-icon type="plus-circle" theme="filled" v-if="!uploading5"  />
                       {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                </td>
              </tr>
              <!-- 静态测试报告 -->
              <tr>
                <td class="td1">
                  {{ $t('staticTestReport')+'：' }}
                </td>
                <td class="td2">
                  <span class="mr8 tag" v-for="(item, index) in staticInfoList" :key="index">
                       <a @click="downloadFile(item)">{{item.fileName}}</a>
                       <i class="iconfont icon-shanchu3 deleteUlr" @click="handleRemove('vds_white_report_delete',item.fileId, index)"/>
                  </span>
                </td>
                <td class="td3">
                    <a-upload :multiple="true" :showUploadList="false" :file-list="staticList"  :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_white_report')">
                       <a-button class="mr8" style="border:1px solid #147092;color:#147092"  :loading="uploading6"><a-icon type="plus-circle" theme="filled" v-if="!uploading6"  />
                       {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                </td>
              </tr>
              <!-- 单元测试报告 -->
              <tr>
                <td class="td1">
                  {{ $t('unitTestReport')+'：' }}
                </td>
                <td class="td2">
                  <span class="mr8 tag" v-for="(item, index) in unitInfoList" :key="index">
                       <a @click="downloadFile(item)">{{item.fileName}}</a>
                       <i class="iconfont icon-shanchu3 deleteUlr" @click="handleRemove('vds_util_delete',item.fileId, index)"/>
                  </span>
                </td>
                <td class="td3">
                    <a-upload :multiple="true" :showUploadList="false" :file-list="unitTestList" :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_util')">
                       <a-button class="mr8" style="border:1px solid #147092;color:#147092"  :loading="uploading7"><a-icon type="plus-circle" theme="filled" v-if="!uploading7"  />
                       {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                </td>
              </tr>
              <!-- 集成测试报告 -->
              <tr>
                <td class="td1">
                  {{ $t('integrationTestReport')+'：' }}
                </td>
                <td class="td2">
                  <span class="mr8 tag" v-for="(item, index) in integrationInfoList" :key="index">
                       <a @click="downloadFile(item)">{{item.fileName}}</a>
                       <i class="iconfont icon-shanchu3 deleteUlr" @click="handleRemove('vds_integration_delete',item.fileId, index)"/>
                  </span>
                </td>
                <td class="td3">
                    <a-upload :multiple="true" :showUploadList="false" :file-list="integrationList" :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_integration')">
                       <a-button class="mr8" style="border:1px solid #147092;color:#147092"  :loading="uploading8"><a-icon type="plus-circle" theme="filled" v-if="!uploading8"  />
                       {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                </td>
              </tr>
              <!-- 黑盒测试与匹配报告 -->
              <tr>
                <td class="td1">
                  <span class="requiredStar">*</span>
                  {{ $t('blackBoxMatchReport')+'：' }}
                </td>
                <td class="td2">
                   <span class="mr8 tag" v-for="(item, index) in blackTestInfoList" :key="index">
                      <a @click="downloadFile(item)">{{item.fileName}}</a>
                      <i class="iconfont icon-shanchu3 deleteUlr" @click="handleRemove('vds_report_delete',item.fileId, index)"/>
                  </span>
                </td>
                <td class="td3">
                    <a-upload :multiple="true" :showUploadList="false" :file-list="blackTestList" :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_report')">
                       <a-button class="mr8" style="border:1px solid #147092;color:#147092"  :loading="uploading9"><a-icon type="plus-circle" theme="filled" v-if="!uploading9"  />
                       {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                </td>
              </tr>
              <!-- 软件释放单 -->
              <tr>
                <td class="td1">
                  <span class="requiredStar">*</span>
                  {{ $t('softwareReleaseSheet')+'：' }}
                </td>
                <td class="td2">
                  <span class="mr8 tag" v-for="(item, index) in releaseInfoList" :key="index">
                       <a @click="downloadFile(item)">{{item.fileName}}</a>
                       <i class="iconfont icon-shanchu3 deleteUlr" @click="handleRemove('vds_release_delete',item.fileId, index)"/>
                  </span>
                </td>
                <td class="td3">
                    <a-upload :multiple="true" :showUploadList="false" :file-list="releaseList"  :before-upload="beforeUpload" :customRequest="(file)=>doUpload(file,'vds_release')">
                       <a-button class="mr8" style="border:1px solid #147092;color:#147092"  :loading="uploading10"><a-icon type="plus-circle" theme="filled" v-if="!uploading10"  />
                       {{ $t('uploadAttachment') }}
                      </a-button>
                    </a-upload>
                </td>
              </tr>
            </table>
          </a-form-model-item>
        </a-card>
        <!-- 发布说明 -->
        <a-card class="card-radius" id="sw-step-5">
          <!-- <p class="customFormModelItem2">{{ $t('releaseNote') }}</p> -->
          <a-form-model-item>
            <a-row>
              <!-- 版本描述 -->
              <a-col :md="24" :sm="24">
                    <a-form-model-item prop="versionDesc">
                      <span slot="label">
                         <span class="requiredStar">*</span>
                      {{ $t('versionDescription') }}
                      </span>
                      <a-textarea :rows="4" v-model="formData.versionDesc" :maxLength="500" :placeholder="versionDescTip"/>
                      <span class="tip">{{ countVersionDesc }}/500</span>
                    </a-form-model-item>
                  </a-col>
            </a-row>
            <a-row  style="margin-top:10px;">
              <!-- 功能新增 -->
              <a-col :md="24" :sm="24">
                    <a-form-model-item prop="funcFeature">
                      <span slot="label">
                         <span class="requiredStar">*</span>
                      {{ $t('funcAdd') }}
                      </span>
                      <a-textarea :rows="4" v-model="formData.funcFeature" :placeholder="$t('pleaseInput')+$t('funcAdd')+'...'" :maxLength="500" />
                      <span class="tip">{{ countFuncFeature }}/500</span>
                    </a-form-model-item>
                  </a-col>
            </a-row>
            <a-row style="margin-top:10px;">
              <!-- 功能优化 -->
              <a-col :md="24" :sm="24">
                    <a-form-model-item prop="funcOptimize">
                       <span slot="label">
                         <span class="requiredStar">*</span>
                          {{ $t('funcOptimize') }}
                      </span>
                      <a-textarea :rows="4" v-model="formData.funcOptimize" :placeholder="$t('pleaseInput')+$t('funcOptimize')+'...'" :maxLength="500" />
                      <span class="tip">{{ countFuncOptimize }}/500</span>
                    </a-form-model-item>
                  </a-col>
                <!-- </a-row>
              </a-col> -->
            </a-row>
            <a-row style="margin-top:10px;">
              <!-- 特别鸣谢 -->
              <a-col :md="24" :sm="24">
                    <a-form-model-item>
                      <span slot="label">
                         <!-- <span class="requiredStar">*</span> -->
                          {{ $t('specialThanks') }}
                      </span>
                      <a-textarea :rows="4" v-model="formData.specialThanks" :placeholder="$t('pleaseInput')+$t('specialThanks')+'...'" :max-length="500" />
                      <span class="tip">{{ countSpecialThanks }}/500</span>
                    </a-form-model-item>
                  </a-col>
            </a-row>
          </a-form-model-item>
        </a-card>
        <!-- 审批流程 -->
        <a-card class="card-radius" id="sw-step-6">
          <!-- <p class="customFormModelItem2">{{ $t('auditProcess') }}</p> -->
          <!-- 申请人信息 -->
          <a-form-model-item>
            <a-row :gutter="36">
              <!-- 申请人姓名 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item>
                      <span slot="label">
                      {{ $t('name2') }}
                    </span>
                      <a-input :disabled="true" :value="formData.applyUserName.substring(0,formData.applyUserName.indexOf('('))||'-'"></a-input>
                    </a-form-model-item>
              </a-col>
              <!-- 工号 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item>
                  <span slot="label">
                  {{ $t('jobNumber') }}
                </span>
                  <a-input :disabled="true" :value="formData.applyUserId||'-'" />
                </a-form-model-item>
              </a-col>
              <!-- 邮箱 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item>
                      <span slot="label">
                        {{ $t('email2') }}
                      </span>
                      <a-input :disabled="true" :value="formData.applyUserEmail||'-'" />
                    </a-form-model-item>
              </a-col>
              <!-- 所属组织架构 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item>
                  <span slot="label">
                    {{ $t('org') }}
                  </span>
                  <a-input :disabled="true" :value="formData.applyUserOrgName||'-'" />
                </a-form-model-item>
              </a-col>
              <!-- 电话 -->
              <a-col :md="8" :sm="24">
                <a-form-model-item>
                  <span slot="label">
                    {{ $t('telephone') }}
                  </span>
                  <a-input :disabled="true" :value="formData.applyPhone||'-'" />
                </a-form-model-item>
              </a-col>
              <!-- 申请日期 -->
              <a-col :md="8" :sm="24">
                    <a-form-model-item>
                      <span slot="label">
                        {{ $t('applicationDate') }}
                      </span>
                      <a-input :disabled="true" :value="formData.applyTime||'-'" />
                    </a-form-model-item>
              </a-col>
            </a-row>
          </a-form-model-item>
          <div>
            <!-- <div style="height:360px;margin-bottom: 16px;">
              <process-viewer
                v-if="processView.index"
                :key="`designer-${processView.index}`"
                :finishedInfo="finishedInfo"
                :xml="processView.xmlData"
                style="height:100%"
              />
            </div> -->
            <!-- 审核节点列表 -->
              <!-- v-if="showNoramlProcess" -->
            <audit-flow-process
              ref="auditProcessRef"
              method-name="getSoftwareMCFlowDesinNodeData"
              :candidate="candidateTodraft"
              :applyUserName="formData.applyUserName"
            />
            <!-- <display-unstarted-tb-list :disabled="false" :lists="auditLists" v-else></display-unstarted-tb-list> -->
          <!-- {{showNoramlProcess}} -->
          </div>
        </a-card>
        <!-- 上传文件 -->
        <upload-config-version-file
          ref="uploadFile"
          @saveFile="uploadOk"
          :upgradePackType="formData.upgradePackType"
          :modelCode="formData.modelCode"
          :ecuId="formData.ecuId"
          :softwareCode="formData.softwareCode"
          :uploadFile="fileList"
          :isConfigFile="formData.isConfigFile"
          :versionNumber="formData.versionNumber"
        />
        <!-- 查看摘要值 -->
        <a-modal v-model="showCheckSum" :title="$t('zyz')">
          <template slot="footer">
            <a-button key="back" @click="showCheckSum=false">{{ $t('back') }}</a-button>
          </template>
          <p>{{ checkSumToModal }}</p>
        </a-modal>
        <!-- 编辑文件信息 -->
        <edit-uploaded-file ref="editFile" @saveForm="editedOk" />
      </a-form-model>
    </div>
     <!-- 在线差分 -->
    <online-difference
      ref="onlineDifference"
      :selectedVersion="selectedVersion"
      @addOrEditDone="handleRefreshTable"
    ></online-difference>
    <!-- 下方操作栏 -->
    <!-- <div class="EditSoftwareMCFooter">
      <a-button style="margin-right: 24px" @click="handleCancel">{{ $t('cancel') }}</a-button>
      <auth-button style="margin-right: 24px" @click="handleSubmitAsDraft" :disabled="disableSaveDraft">{{ $t('saveAsDraft') }}</auth-button>
      <auth-button @click="handleSubmit" :loading="saving">{{ $t('save') }}</auth-button>
    </div> -->
  </div>
</template>
<script>
import { todoPerms } from '@/config/permission/index'
import OnlineDifference from './components/OnlineDifference'
import AuthButton from '@/components/AuthButton'
import lodash from 'lodash'
import fileUploadApi from '@/api/modules/system/fileUpload'
import QuestionMarkTip from '@/views/components/QuestionMarkTip'
import swSteps from '@/views/components/step/swSteps'
import TableEllipsis from '@/components/Ellipsis/TableEllipsis'
import UploadConfigVersionFile from './components/UploadFile.vue'
import EditUploadedFile from './components/EditUploadedFile.vue'
import AuditFlowProcess from '@/views/components/AuditFlowProcess/config.vue'
import ChunkUpload from '@/components/Upload/ChunkUpload'
import ProcessViewer from '@/components/ProcessViewer'
import DisplayUnstartedTbList from '@/views/components/AuditFlowProcess/displayEditableTb.vue'
import { mapState } from 'vuex'
import SparkMD5 from 'spark-md5'
import CryptoJS from 'crypto-js'
import moment from 'moment'
import { checkVersionNameWithOutV,checkTextLen } from '@/utils/validate'
import {axios} from '@/utils/request'
import { checkIsRangeInteger,checkIsRangeText } from '@/utils/validate'
import { DOWNLOAD_FILE_WITH_ID } from '@/config/fetchURL'
import { downloadBlobFile } from '@/utils/functions'
import { debounce } from '@/utils/util'
import { minxinScrollTop } from '@/utils/mixin.js'
// eslint-disable-next-line max-len
import {
  uploadedFileTableColumns,
  softwareDistributionScopeEnumArr,
  changeAttributeEnumArr,
  problemLevelEnumArr,
  degreeOfUrgencyEnumArr,
  userPerceptionEnumArr,
  stateSummaryEnumArr,
  yesOrNoEnumArr,
  yesOrNoEnumArrString,
  flushTypeEnumArr,
  updateFileTypeEnumArr,
  mainProgramTbColumns,
  mainProgramTbColumnsSelected,
  targetVersionColumns,
  softwareChangeColumns
} from './config/list'
import { writeFileStream } from '@/utils/functions'

export default {
  mixins:[minxinScrollTop],
  components: {
    AuthButton,
    TableEllipsis,
    QuestionMarkTip,
    swSteps,
    ProcessViewer,
    UploadConfigVersionFile,
    AuditFlowProcess,
    EditUploadedFile,
    DisplayUnstartedTbList,
    ChunkUpload,
    OnlineDifference
  },
  data() {
    const checkCompatibleVersion = (rule, value, callback) => {
      this.totalLength=0
      if (this.formData.compatibleVersion && this.formData.compatibleVersion.length > 0) {
        // eslint-disable-next-line consistent-return
        this.formData.compatibleVersion.forEach(item => {
          if (!/^(\d+\.){2,}\d+$/.test(item) || item.length > 50) {
            return callback(new Error(this.$t('inputVersionNameWithoutVTip1')))
          }
          this.totalLength=this.totalLength+item.length
        })
        this.totalLength=this.totalLength+this.formData.compatibleVersion.length-1
        if(this.totalLength>200){
          return callback(new Error(this.$t('inputVersionListMaxLength')))
        }
        return callback()
      }
      return callback(new Error(this.$t('compatibleVersionBlankError')))
    }
    return {
      todoPerms,
      endTime: undefined,
      status: this.$route.query.status,
      fromApplication:false,
      from:this.$route.query.from||'',
      targetId:'',
      selectedVersion:[],
      encryptType:0,
      opeartion:0,
      totalLength:0,
      formLayout: 'horizontal',
      dataFormTb: [],
      onlineDifference:false,
      // 已选中表单数据
      dataSelected: [],
      dataSelectedTransit: [],
      burnSpecificationTip:`更新条件警示：\n 1.整车上ON档电\n 2.更新过程中保持设备正常连接\n 3.更新失败请重新执行或通过异常列表处理`,
      versionDescTip:`示例：当前软件发布用于哪类车辆（工程院项目组车，领导试驾车）以及使用目的（路试，公告）等`,
      // 上传材料列表
      timer:null,
      verifyList:[],
      overSeasList:[],
      ECNList:[],
      testPlanList: [],
      demandList: [],
      staticList: [],
      unitTestList: [],
      integrationList: [],
      blackTestList: [],
      releaseList: [],
      // 上传材料信息
      verifyInfoList:[],
      overSeasInfoList:[],
      ECNInfoList:[],
      testInfoList: [],
      demandInfoList: [],
      staticInfoList: [],
      unitInfoList: [],
      integrationInfoList: [],
      blackTestInfoList: [],
      releaseInfoList: [],
      disablePackage:false,
      // 工程院项目主管列表
      engineerSupervisorList:[],
      planningSupervisorList:[],
      formData: {
        // 二期需要沟通
        engTestVerdict:'通过',
        repDemandMust:false,
        applyDemandReason:'无',
        repIntegrateMust:false,
        applyIntegrateReason:'无',
        repMust:true,
        repPlanMust:false,
        applyPlanReason:'无',
        repReleaseMust:true,
        repUnitMust:false,
        applyUnitReason:'无',
        repWhiteMust:false,
        applyWhiteReason:'无',
        files:[],
        applyTime: null,
        applyUserOrgName: '',
        applyUserName: '',
        applyUserId:'',
        applyUserEmail: '',
        applyPhone:'',
        isConfigFile: 0,
        softwareCode: undefined,
        dllName:undefined,
        bootVer:'',
        isEmergency:undefined,
        perceptible:undefined,

        softStageDetailSupplier:undefined,
        stateSum:undefined,
        emergencyReason:'',
        problemsSum:'',
        impressApprove:undefined,
        impressCarType:'',
        timeout:9000,
        proDate:null,
        hardVersion:undefined,
        hardVersionDate:null,
        contactPersonId:undefined,
        contactPersonId:undefined,
        contactPersonName:'',
        creatorId:undefined,
        creatorId:undefined,
        creatorName:'',
        criterion:'',
        overLawsChange:undefined,
        overParameters:undefined,
        carDevStage:undefined,
        technicalFeature:undefined,
        technicalParameters:'',
        notice:undefined,
        compatibleVersion: undefined,
        modelCode: undefined,
        ecuId: undefined,
        mainChip:'',
        partNo:'',
        subType:'',
        // modelConfigure:'',
        vehiclePam:'',
        softPurpose:undefined,
        softPurposeSupplier:undefined,
        changeExplains: [],
        ecuName: '',
        versionNumber: undefined,
        versionCode: moment().format('YYYYMMDDHHmmss'),
        candidates: [],
        upgradePacks: [],
        upgradePackType: undefined,
        ecuReprogramType: [],
        funcOptimize: '',
        specialThanks: '',
        funcFeature: '',
        versionDesc: '',
      },
      selectedRowKeys: [],
      processList: [],
      finishedInfo: {
        finishedSequenceFlowSet: [],
        finishedTaskSet: [],
        unfinishedTaskSet: [],
        rejectedTaskSet: []
      },
      processView: {
        index: '',
        xmlData: ''
      },
      columns: uploadedFileTableColumns,
      formItemLayout: {
        labelCol: { span: 20 },
        wrapperCol: { span: 24 }
      },
      yesOrNoEnumArr,
      yesOrNoEnumArrString,
      softwareDistributionScopeEnumArr,
      changeAttributeEnumArr,
      problemLevelEnumArr,
      degreeOfUrgencyEnumArr,
      userPerceptionEnumArr,
      stateSummaryEnumArr,
      softwareUseEnumArr:[],
      softUseEngineer:[],
      ecuOptionArr: [],
      carDevStageArr: [],
      dllNameArr: [],
      isUpdateFile: 1,
      isPass:1,
      isSoftwareRelese:0,
      flushTypeEnumArr,
      updateFileTypeEnumArr,
      filterEcuList: [],
      flushTypeEnumArr2: [],
      fileFlushTypeEnumArr: [],
      mainProgramTbColumns,
      mainProgramTbColumnsSelected,
      targetVersionColumns,
      softwareChangeColumns,
      fileList: [],
      disableFlushBtn: true,
      fileName:'',
      rules: {
        // 软件变更字段验证
        changeBefore: [{ required: true, message:this.$t('pleaseInput') },{ validator: checkTextLen(1000, true) }],
        inflectContent: [{ required: true, message:this.$t('pleaseInput')},{ validator: checkTextLen(1000, true) }],
        function: [{ required: true, message:this.$t('pleaseInput')},{ validator: checkTextLen(1000, true) }],
        affect: [{ required: true, message:this.$t('pleaseInput')},{ validator: checkTextLen(1000, true) }],
        purpose: [{ required: true, message: this.$t('pleaseInput')},{ validator: checkTextLen(1000, true) }],
        property: [{ required: true, message: this.$t('pleaseSelect')}],
        questionLevel: [{ required: true, message: this.$t('pleaseSelect')}],
        modelCode: [{ required: true, message: this.$t('pleaseSelect') }],
        ecuId: [{ required: true, message: this.$t('pleaseSelect') }],
        mainChip: [{ required: true, message: this.$t('mainChipFormat') },{ validator: checkTextLen(100, true) }],
        partNo: [{ required: true, message: this.$t('pleaseInput') },{ validator: checkTextLen(500, true) }],
        vehiclePam: [{ required: true, message: this.$t('pleaseSelect') }],
        softPurpose: [{ required: true, message: this.$t('pleaseSelect') }],
        softPurposeSupplier: [{ required: true, message: this.$t('pleaseSelect') }],
        softwareCode: [{ required: true, message: this.$t('pleaseSelect') }],
        versionNumber: [{ required: true, message: this.$t('pleaseInput') },
        { validator: checkVersionNameWithOutV(), trigger: 'change', required: true },
        { validator: checkVersionNameWithOutV(), trigger: 'blur', required: true }],
        versionCode: [
          {
            pattern: /^[1-9]\d*$/,
            message: this.$t('versionCodeErrorTip')
          },
          { required: true, message: this.$t('pleaseInput') }
        ],
        dllName: [{ required: true, message: this.$t('pleaseSelect') }],
        isEmergency: [{ required: true, message: this.$t('pleaseSelect') }],
        perceptible: [{ required: true, message: this.$t('pleaseSelect') }],
        softStageDetailSupplier: [{ required: true, message: this.$t('pleaseSelect'),validator: (rule, value, callback) => {
            if (!value && value !== 0 && this.formData.softPurposeSupplier=='SOFTWARE_RELEASE') {
              callback(new Error(this.$t('pleaseInput')));
            } else {
              callback();
            }
          }
         }],
        stateSum: [{ required: true, message: this.$t('pleaseSelect') }],
        emergencyReason: [{ required: true, message: this.$t('pleaseInput'),validator: (rule, value, callback) => {
            if (!value && value !== 0 && this.formData.isEmergency) {
              callback(new Error(this.$t('pleaseInput')));
            } else {
              callback();
            }
          }
         },
        //  { validator: checkTextLen(500, true) }
         ],
        problemsSum: [{ required: false, message: this.$t('pleaseInput') }],
        impressApprove: [{ required: true, message: this.$t('pleaseSelect') }],
        impressCarType: [{ required: true, message: this.$t('pleaseInput'),validator: (rule, value, callback) => {
            if (!value && value !== 0 && this.formData.impressApprove) {
              callback(new Error(this.$t('pleaseInput')));
            } else {
              callback();
            }
          }
        },
        // { validator: checkTextLen(500, true) }
        ],
        criterion: [{ required: true, message: this.$t('pleaseInput') },{ validator: checkIsRangeText(20, 200) }],
        contactPersonId: [{ required: true, message: this.$t('pleaseSelect') }],
        creatorId: [{ required: true, message: this.$t('pleaseSelect') }],
        timeout: [{ required: true, message: this.$t('pleaseInput') },{ validator: checkIsRangeInteger(1, 2147483647) }],
        'upgradePacks[0].installSec': [{ required: true, message: this.$t('pleaseInput') },{ validator: checkIsRangeInteger(1, 2147483647) }],
        'upgradePacks[0].fileReprogramType': [{ required: true, message: this.$t('pleaseSelect') }],
        bootVer: [{ required: true, message: this.$t('pleaseInput') },{ validator: checkTextLen(500, true)}],
        proDate	: [{ required: true, message: this.$t('pleaseSelect') }],
        hardVersion	: [{ required: true, message: this.$t('pleaseInput') },{ validator: checkTextLen(60, true)}],
        hardVersionDate	: [{ required: true, message: this.$t('pleaseSelect') }],
        overLawsChange: [{ required: true, message: this.$t('pleaseSelect') }],
        overParameters: [{ required: true, message: this.$t('pleaseSelect'),validator: (rule, value, callback) => {
            if (!value && value !== 0 && this.formData.overLawsChange) {
              callback(new Error(this.$t('pleaseInput')));
            } else {
              callback();
            }
          } }
        ],
        carDevStage: [{ required: true, message: this.$t('pleaseSelect') }],
        technicalFeature: [{ required: true, message: this.$t('pleaseSelect') }],
        technicalParameters: [{ required: true, message: this.$t('pleaseInput') , validator: (rule, value, callback) => {
            if (!value && value !== 0 && this.formData.technicalFeature&&this.formData.notice) {
              callback(new Error(this.$t('pleaseInput')));
            } else {
              callback();
            }
          } },
        // { validator: checkTextLen(2000, true)}
        ],
        notice : [{ required: true, message: this.$t('pleaseSelect'), validator: (rule, value, callback) => {
            if (!value && value !== 0 && this.formData.technicalFeature) {
              callback(new Error(this.$t('pleaseInput')));
            } else {
              callback();
            }
          } }],
        upgradePackType: [{ required: true, message: this.$t('pleaseSelect') }],
        ecuReprogramType: [{ required: true, message: this.$t('pleaseSelect') }],
        funcOptimize: [{ required: true, message: this.$t('pleaseInput') }],
        funcFeature: [{ required: true, message: this.$t('pleaseInput') }],
        versionDesc: [{ required: true, message: this.$t('pleaseInput') }],
        compatibleVersion: [{ required: true, message: this.$t('pleaseSelect') },
        { validator: checkCompatibleVersion, trigger: 'change', required: true },
        { validator: checkCompatibleVersion, trigger: 'blur', required: true }
        ]
      },
      verisonList: [],
      TransitList: [],
      carModelArr: [],
      disableSaveDraft: true,
      disableUpload: false,
      checkSumToModal: '',
      showCheckSum: false,
      digestAlgorithmEnum: [
        { value: 1, name: 'MD5' },
        { value: 2, name: 'SHA256' }
      ],
      isManualEntry: false,
      candidateTodraft: [],
      fisrtLoadEcuIdFlag: true,
      isReapt: false,
      noEditModel: false,
      loadDraftDone: false,
      versionNumber: '',
      ecuReprogramType: '',
      compatibleVersion: '',
      triggerWatch: true,
      searchRelatedFormName: '',
      showNoramlProcess: true,
      auditLists: [],
      configFile: { fileObject: {} },
      uploading: false,
      uploading1: false,
      uploading2: false,
      uploading3: false,
      uploading4: false,
      uploading5: false,
      uploading6: false,
      uploading7: false,
      uploading8: false,
      uploading9: false,
      uploading10: false,
      dictCode:'sw_repo_soft_usage',
      saving: false,
      pageInfo: {
        pageSize: 10,
        pageNo: 1,
        totalCount: 0,
        totalPage: 0
      }
    }
  },
  computed: {
    ...mapState({
      // 摘要算法
      digestAlgorithm: state => state.dict.digestAlgorithm
    }),
    isContactPersonId:function () {
      return this.formData.upgradePackType==1&&this.formData.ecuReprogramType=='ata_reprogram'
    },
    countFuncOptimize () {
      if (this.formData.funcOptimize) {
        return this.formData.funcOptimize.length
      }
      return 0
    },
    countSpecialThanks () {
      if (this.formData.specialThanks) {
        return this.formData.specialThanks.length
      }
      return 0
    },
    countVersionDesc () {
      if (this.formData.versionDesc) {
        return this.formData.versionDesc.length
      }
      return 0
    },
    countFuncFeature () {
      if (this.formData.funcFeature) {
        return this.formData.funcFeature.length
      }
      return 0
    }
  },
  watch: {
    'formData.modelCode'(val) {
      const vm = this
      if (val) {
        vm.disableSaveDraft = false
        vm.$api.getECUSelectOption({ code: val, selectAll: true }).then(response => {
          vm.ecuOptionArr = response.data || []
        })
        vm.carModelArr.forEach(item => {
          if (item.value === val) {
            vm.formData.modelName = item.name
            if (vm.formData.isConfigFile === 1) {
              vm.searchRelatedForm()
            }
          }
        })
      } else {
        this.disableSaveDraft = true
        // vm.searchRelatedForm()
      }
    },
    'formData.ecuId' (newVal, oldVal) {
        const vm = this
        if ((vm.$route.query.t === '3' || vm.$route.query.t === '5'|| vm.$route.query.t === '7'|| vm.$route.query.t === '9') && vm.fisrtLoadEcuIdFlag) {
          vm.fisrtLoadEcuIdFlag = false
        } else {
          // 新建表单的时候，更改ecu需要清空软件编码
          vm.formData.softwareCode = undefined
          this.$refs['newEditForm'].clearValidate(['compatibleVersion']);
        }
        // 重新请求ecu下拉
        vm.filterEcuList = []
        if (vm.formData.ecuId) {
          vm.getSoftwareOptions()
        }
    },
    'formData.softwareCode'(newVal, oldVal) {
      if ((this.$route.query.t === '3'&& this.loadDraftDone) ||( this.$route.query.t === '5')||( this.$route.query.t === '7') ) {
        if (this.formData.softwareCode!=undefined&&this.formData.softwareCode!='') {
          // this.clearCompatibleVersion()
          this.queryCompatibleVersion()
        }
          this.triggerWatch = true
      } else if (this.$route.query.t !== '3' && this.$route.query.t !== '5') {
        const vm = this
        vm.formData.compatibleVersion = undefined
        if (vm.formData.softwareCode) {
          vm.clearCompatibleVersion()
          vm.queryCompatibleVersion()
        }
      }
    },
    'formData.upgradePackType' (newVal, oldVal) {
      if (this.$route.query.t === '5'&& this.loadDraftDone|| (this.$route.query.t === '3'&& this.loadDraftDone)) {
        if (this.triggerWatch&&newVal!=undefined) {
          this.confimrEditDraftBasicInfo('upgradePackType', 'sjblx', oldVal)
        } else {
          this.triggerWatch = true
        }
      }
      if(this.formData.upgradePackType==2){
        this.disablePackage=true
      }else if(this.formData.upgradePackType==1){
        this.disablePackage=false
      }
    },
    'formData.isConfigFile':{
      handler(){
        if (this.formData.isConfigFile === 1) {
          this.$api.searchFlushTypeRelated(1).then(res => {
            this.flushTypeEnumArr2 = res.data
          })
          this.disableFlushBtn = false
        }
      }
    },
    isUpdateFile:{
      handler(){
        this.$nextTick(() => {
          this.getScrollHeight()
        })
      }
    },
    formData:{
      deep: true,
      handler(){
        this.$nextTick(() => {
          this.getScrollHeight()
        })
      }
    },
  },
  created() {
    this.formData.criterion=this.burnSpecificationTip
    this.getProcessXmlData()
    this.getSoftwareUse()
    this.getSoftUseEngineer()
    this.getCarDevStageArr()
    this.getDllNameArr()
    this.getApplicationPersonArr()
    this.getPlanningPersonArr()
    // 判断是否从我的申请跳转过来
    if(this.$route.query.aorr === 'a'){
      this.fromApplication = true
    }
  },
  mounted() {
    const vm = this
    // t 表示软件管控的表单来源，3代表编辑表单草稿,5代表加工失败的表单,7代表复制表单,9代表在线差分
    if (this.$route.query.t === '3') {
      this.noEditModel = true
      this.opeartion=0
      this.$api.getDraftDetail(this.$route.query.id).then(res => {
        this.formData = JSON.parse(res.data.businessContent)
        if(this.formData.formFileBuilderType){
          this.onlineDifference=true
          this.targetId=this.formData.ID
          this.selectedVersion=this.formData.selectedVersion
          console.log(this.targetId,'101010')
        }
        if (!this.formData.compatibleVersion) {
          this.$set(this.formData, 'compatibleVersion', undefined)
        }
        this.fileList = this.formData.upgradePacks
        this.candidateTodraft = this.formData.candidates
         this.verifyInfoList=this.formData.files.filter(item=>item.bizName=='vds_verify')
          this.overSeasInfoList=this.formData.files.filter(item=>item.bizName=='vds_over_verify')
          this.ECNInfoList=this.formData.files.filter(item=>item.bizName=='vds_ecn_ecr')
          this.testInfoList= this.formData.files.filter(item=>item.bizName=='vds_plan')
          this.demandInfoList= this.formData.files.filter(item=>item.bizName=='vds_demand')
          this.staticInfoList= this.formData.files.filter(item=>item.bizName=='vds_white_report')
          this.unitInfoList= this.formData.files.filter(item=>item.bizName=='vds_util')
          this.integrationInfoList= this.formData.files.filter(item=>item.bizName=='vds_integration')
          this.blackTestInfoList= this.formData.files.filter(item=>item.bizName=='vds_report')
          this.releaseInfoList= this.formData.files.filter(item=>item.bizName=='vds_release')
        // 如果是配置文件，要显示不同的板块
        if (this.formData.isConfigFile === 1) {
          vm.$api.searchFlushTypeRelated(1).then(res => {
            vm.flushTypeEnumArr2 = res.data
          })
          if (vm.formData.upgradePacks[0]) {
            vm.isManualEntry = !(!vm.formData.upgradePacks[0].isManualEntry)
            if (vm.formData.upgradePacks[0].configFile) {
              vm.configFile = vm.formData.upgradePacks[0].configFile
              vm.handleUploadDone()
            }
          }
          this.isUpdateFile = false
          this.disableFlushBtn = false
          vm.$api.searchFlushTypeRelated(1).then(res => {
                vm.flushTypeEnumArr2 = res.data
          })
          // eslint-disable-next-line max-len
          this.$api.getSoftwareMCList({ shelveStatus: 10, modelCode: this.formData.modelCode, ecuId: this.formData.ecuId, isConfigFile: 0, pageSize: this.pageInfo.pageSize, pageNo: this.pageInfo.pageNo }).then(res => {
            this.dataFormTb = res.data
            this.pageInfo.totalCount = res.totalCount
            this.pageInfo.totalPage = res.totalPag
          }).finally(() => {
            if(this.formData.applyIds&&this.formData.applyIds.length>0){
              this.dataFormTb.forEach((item) => {
                this.formData.applyIds.forEach(item2 => {
                  if (item2 === item.id) {
                    this.selectedRowKeys.push(item2)
                     this.dataSelected.push(item)
                  }
                })
              })
            }

          })
        }
          // 如果选择了升级包类型就要取消后面烧写类型的禁用，并且获取对应下拉框
          if (this.formData.upgradePackType) {
            const vm = this
            if (vm.formData.upgradePackType === 1) {
              if(vm.formData.upgradePacks.length > 0){
                vm.disableUpload = true
              }else{
                 vm.disableUpload = false
              }
              vm.$api.searchFlushTypeRelated(1).then(res => {
                vm.flushTypeEnumArr2 = res.data
                vm.disableFlushBtn = false
              })
            } else {
              const vm = this
              vm.$api.searchFlushTypeRelated(2).then(res => {
                vm.flushTypeEnumArr2 = res.data
                vm.disableFlushBtn = false
              })
            }
          }

        if(this.formData.stateSum!=1){
          this.isPass=false
          this.rules.problemsSum[0].required=true
        }else{
          this.isPass=true
          this.rules.problemsSum[0].required=false
        }
        if(this.formData.softPurposeSupplier=='SOFTWARE_RELEASE'){
           this.isSoftwareRelese=true
        }
        })
        .finally(() => {
          this.loadDraftDone = true
        })
    }
    if (this.$route.query.t === '5') {
      this.noEditModel = true
       this.opeartion=1
      this.showNoramlProcess = false
      if(this.$route.query.diff){
         this.onlineDifference=true
         this.$api.getOnlineDiffTargetId(this.$route.query.originalId).then(res=>{
           this.targetId=res.data
         })
      }
      // eslint-disable-next-line max-len
      this.$api.getDraftFlowInstanceDetail({ businessCode: 'sw_repo_audit', businessKey: this.$route.query.originalId }).then(res => {
        this.auditLists = res.data
        this.auditLists.unshift({
          "flowElementName": "申请人",
          "canResultNotice": '',
          "canInstanceCancelNotice": '',
          "assignee":this.formData.applyUserName,
          "roleCandidates": null,
          "processModeDesc": "-"
        })
      })
      this.$api.queryFormDetail(this.$route.query.originalId).then(res => {
        // 已经被删除
        if (res.data.deleted === 1) {
          vm.$store.dispatch('tagsView/delView', vm.visitedViews.at(-1))
            .then(() => {
              vm.$message.warning(vm.$t('sjyscwfjxbj'))
              // eslint-disable-next-line max-len
              vm.$router.replace({ path: vm.visitedViews.at(-1).path, params: vm.visitedViews.at(-1).params, query: vm.visitedViews.at(-1).query })
            }
            )
        }
        this.formData = res.data
        // 将布尔类型转化成数字类型，与字典、下拉框对应
        this.formData.vehiclePam=Number(this.formData.vehiclePam)
        this.formData.technicalFeature=Number(this.formData.technicalFeature)
        this.formData.notice=Number(this.formData.notice)
        if(!this.formData.technicalFeature){
          this.formData.notice=undefined
        }
        this.formData.overLawsChange=Number(this.formData.overLawsChange)
        this.formData.isEmergency=Number(this.formData.isEmergency)
        // this.formData.perceptible=Number(this.formData.perceptible)
        this.formData.impressApprove=Number(this.formData.impressApprove)

        this.verifyInfoList=res.data.files.filter(item=>item.bizName=='vds_verify')
        this.overSeasInfoList=res.data.files.filter(item=>item.bizName=='vds_over_verify')
        this.ECNInfoList=res.data.files.filter(item=>item.bizName=='vds_ecn_ecr')
        this.testInfoList= res.data.files.filter(item=>item.bizName=='vds_plan')
        this.demandInfoList= res.data.files.filter(item=>item.bizName=='vds_demand')
        this.staticInfoList= res.data.files.filter(item=>item.bizName=='vds_white_report')
        this.unitInfoList= res.data.files.filter(item=>item.bizName=='vds_util')
        this.integrationInfoList= res.data.files.filter(item=>item.bizName=='vds_integration')
        this.blackTestInfoList= res.data.files.filter(item=>item.bizName=='vds_report')
        this.releaseInfoList= res.data.files.filter(item=>item.bizName=='vds_release')

        if (this.formData.ecuReprogramType) {
          this.formData.ecuReprogramType = res.data.ecuReprogramType.split(',')
        }
        // 文件加工失败的差分包，打开编辑需要清除兼容版本
        // this.formData.upgradePackType !== 1 代表着升级包类型不为全包时
        // upgradePackType === 1 为全包
        // upgradePackType === 2 为差分包
        if (this.formData.compatibleVersion && this.formData.upgradePackType !== 1) {
          this.clearCompatibleVersion()
        } else if (this.formData.compatibleVersion) {
          this.formData.compatibleVersion = res.data.compatibleVersion.split(',')
        }
        // this.fileList = this.formData.upgradePacks
        if(this.formData.softPurposeSupplier=='SOFTWARE_RELEASE'){
           this.isSoftwareRelese=true
        }
        this.candidateTodraft = this.formData.candidates
        // 如果是配置文件，要显示不同的板块
        if (this.formData.isConfigFile === 1) {
          if (vm.formData.upgradePacks[0].checksum) {
            vm.isManualEntry = vm.formData.upgradePacks[0].isManualEntry
            if (vm.formData.upgradePacks[0].configFile) {
              vm.configFile = vm.formData.upgradePacks[0].configFile
              vm.handleUploadDone()
            }
          }
          this.isUpdateFile = false
          this.disableFlushBtn = false
          // eslint-disable-next-line max-len
          this.$api.getSoftwareMCList({
            shelveStatus: 10,
            modelCode: this.formData.modelCode,
            ecuId: this.formData.ecuId,
            isConfigFile: 0,
            pageSize:this.pageInfo.pageSize,
            pageNo: this.pageInfo.pageNo
          }).then(res => {
            this.dataFormTb = res.data
            this.pageInfo.totalCount = res.totalCount
            this.pageInfo.totalPage = res.totalPage
          }).finally(() => {
            if(this.formData.applyIds&&this.formData.applyIds.length>0){
            this.dataFormTb.forEach((item) => {
              this.formData.applyIds.forEach(item2 => {
                if (item2 === item.id) {
                  this.selectedRowKeys.push(item2)
                  this.dataSelected.push(item)
                }
              })
            })

            }
          })
        }
         vm.clearFileInfo()
        // 如果选择了升级包类型就要取消后面烧写类型的禁用，并且获取对应下拉框
        if (this.formData.upgradePackType) {
            const vm = this
            if (vm.formData.upgradePackType === 1 && vm.formData.upgradePacks.length > 0) {
              vm.disableUpload = true
            } else {
              vm.disableUpload = false
            }
            if (vm.formData.upgradePackType === 1) {
              vm.$api.searchFlushTypeRelated(1).then(res => {
                vm.flushTypeEnumArr2 = res.data
                vm.disableFlushBtn = false
              })
            } else {
              vm.$api.searchFlushTypeRelated(2).then(res => {
                vm.flushTypeEnumArr2 = res.data
              })
            }
        }else{
          const vm = this
          vm.$api.searchFlushTypeRelated(1).then(res => {
            vm.flushTypeEnumArr2 = res.data
            vm.disableFlushBtn = false
          })
        }
        if(this.formData.stateSum!=1){
          this.isPass=false
          this.rules.problemsSum[0].required=true
        }else{
          this.isPass=true
          this.rules.problemsSum[0].required=false
        }
      })
      .finally(() => {
        this.loadDraftDone = true
        this.disableSaveDraft = true
      })
    }
    // 复制表单
    if(this.$route.query.t === '7'){
       this.opeartion=0
        this.$api.getCopyDetail(this.$route.query.originalId).then(res=>{
        this.formData={...this.formData,...res.data}
         // 如果是配置文件，要显示不同的板块
        if (this.formData.isConfigFile === 1) {
          this.clearFileInfo()
          this.isUpdateFile = false
          this.$api.getSoftwareMCList({
            shelveStatus: 10,
            modelCode: this.formData.modelCode,
            ecuId: this.formData.ecuId,
            isConfigFile: 0,
            pageSize:this.pageInfo.pageSize,
            pageNo: this.pageInfo.pageNo
          }).then(res => {
            this.dataFormTb = res.data
            this.pageInfo.totalCount = res.totalCount
            this.pageInfo.totalPage = res.totalPage
          }).finally(() => {
          })
        }
       })
    }
    // 在线差分表单
    if(this.$route.query.t === '9'){
      this.opeartion=1
      this.onlineDifference=true
      this.$api.getDiffCopyDetail(this.$route.query.originalId).then(res=>{
        this.formData={...this.formData,...res.data} 
         // 如果是配置文件，要显示不同的板块
        if (this.formData.isConfigFile === 1) {
          this.clearFileInfo()
          this.isUpdateFile = false
          this.$api.getSoftwareMCList({
            shelveStatus: 10,
            modelCode: this.formData.modelCode,
            ecuId: this.formData.ecuId,
            isConfigFile: 0,
            pageSize:this.pageInfo.pageSize,
            pageNo: this.pageInfo.pageNo
          }).then(res => {
            this.dataFormTb = res.data
            this.pageInfo.totalCount = res.totalCount
            this.pageInfo.totalPage = res.totalPage
          }).finally(() => {
          })
        }
      })
      this.formData.upgradePackType=2
        this.$api.searchFlushTypeRelated(2).then(res => {
          this.flushTypeEnumArr2 = res.data
        })
        this.formData.ecuReprogramType='ata_reprogram'
    }


    if(this.formData.softwareCode!=undefined&&this.formData.softwareCode!=''&&this.formData.ecuId!=undefined){
      this.queryCompatibleVersion()
    }
    // 获取申请人信息，并填到提交表单中
    if(this.$route.query.t != '5'){
    this.$api.getApplicantInfo().then(res => {
      this.formData.applyUserName = res.data.applyUserName ? res.data.applyUserName : '-'
      this.formData.applyUserId = res.data.applyUserId ? res.data.applyUserId : '-'
      this.formData.applyUserEmail = res.data.applyUserEmail ? res.data.applyUserEmail : '-'
      this.formData.applyUserOrgName = res.data.applyUserOrgName ? res.data.applyUserOrgName : '-'
      this.formData.applyUserOrgId = res.data.applyUserOrgId ? res.data.applyUserOrgId : '-'
      this.formData.applyTime = res.data.applyTime ? res.data.applyTime : '-'
      this.formData.applyPhone = res.data.applyTime ? res.data.applyPhone : '-'
    })
     }
    this.getModelData()
    // 获取文件烧写类型下拉
    this.$api.searchFlushType().then(res => {
      this.fileFlushTypeEnumArr = res.data.map(item => {
        return { value: item.code, name: item.name }
      })
    })
  },
  methods: { 
    changeDllName(data){
      this.$nextTick(()=>{
        if(this.fileList.length && this.isUpdateFile && !this.onlineDifference){
          this.fileList.forEach(item=>{
            item.fileReprogramType=data
          })
        }
      })
    },
    handleRefreshTable(data,selectKeys){
      // this.fileList=[...data.upgradePackList,...this.fileList]
      this.fileList=data.upgradePackList
      this.formData.upgradePacks = this.fileList
      this.formData.diffOriginalVersions = data.diffOriginalVersionList
      this.formData.compatibleVersion = data.compatibleVersion.split(',')
      this.selectedVersion =selectKeys
    },
    getModelData(value = ''){
      value = Array.isArray(value) ? '': value
      // 获取所有车型下拉
      this.$api.getMyAllModelCode({ selectAll: true, searchWord: value }).then(res => {
        let { data } = res
        if (!data) {
          return
        }
        data = data.map(item => {
          return {
            value: item.code,
            name: item.name
          }
        })
        this.carModelArr = data
      })
    },
    handleAttributeChange(val,record,index){
      record.questionLevel=undefined
    },
    // 切换手动输入
    handleManuallyInputSum ($event) {
      this.isManualEntry = $event
      this.$set(this.formData.upgradePacks[0], 'isManualEntry', $event)
    },
    softwareCodeChange(val){
      const vm = this
      // this.formData.softwareCode=val
      vm.triggerWatch = false
      if (vm.formData.compatibleVersion) {
        vm.formData.compatibleVersion = undefined
      } else {
        vm.triggerWatch = true
      }
      if (vm.formData.softwareCode) {
        vm.clearCompatibleVersion()
        vm.queryCompatibleVersion()
      }
    },
    ecuNameChange(val){
      const vm = this
      vm.clearFileInfo()
      vm.formData.compatibleVersion=[]
      if(vm.formData.upgradePackType == 1){
        vm.disableUpload = false
      }
      vm.searchRelatedForm()
      vm.dataSelected=[]
    },
    updateFileType(val){
      const vm = this
      vm.$refs['newEditForm'].clearValidate(['compatibleVersion']);
      if(val!=undefined){
        vm.disableFlushBtn = false
      }
      if(vm.$route.query.t !== '3'&&vm.$route.query.t !== '5'){
        vm.clearFileInfo()
        if (val === 2) {
          vm.$api.searchFlushTypeRelated(2).then(res => {
            vm.formData.ecuReprogramType = []
            vm.flushTypeEnumArr2 = res.data
          })
        }
        if (val === 1) {
          vm.$api.searchFlushTypeRelated(1).then(res => {
            vm.formData.ecuReprogramType = []
            vm.flushTypeEnumArr2 = res.data
          })
        }
        vm.formData.compatibleVersion=[]
      }
    },
     // 下载模板
    downloadTempFile () {
      this.$api.downloadTemplateFile().then((res) => {
        downloadBlobFile(res, `${this.$t('downloadTemplate')}.xlsx`)
      })
    },

 // 下载上传成功且处理成功的文件
    downloadFile (data) {
      writeFileStream(DOWNLOAD_FILE_WITH_ID + data.fileId, data.fileName)
    },
    // 添加变更说明
    addChangeExplains(){
       if(this.formData.changeExplains.length>=100){
         this.$message.error('软件变更说明最多可以新建100条记录')
         return false
       }
       const newData = {
        serialNo: this.formData.changeExplains.length+1,
        changeBefore: '',
        inflectContent: '',
        function: '',
        affect: '',
        purpose: '',
        property: '',
        questionLevel: '',
      }
      this.formData.changeExplains.push(newData)
    },
    // 删除变更说明
    deleteChangeExplains(data,record,index){
      this.formData.changeExplains.splice(index, 1)
    },
    // 导入附件前验证文件是否是Excel文件
    beforeFileUpload(file){
      const extension = file.name.substring(file.name.lastIndexOf('.') + 1)
      const size = file.size / 1024 / 1024
      if (extension== 'xls'||extension== 'xlsx') {
        return true
      }else{
        this.$message.warning('只能上传excel的文件')
        return false
      }
    },
    // 导入软件变更附件
     fileUpload(options) {
        const formData = new FormData()
        formData.append('file', options.file)
        this.$api.importChangeFile(formData)
          .then(res => {
            this.getValue(res.data)
          })
     },
     getValue(data) {
       if((data.length+this.formData.changeExplains.length)>100){
         this.$message.error('软件变更说明最多可以新建100条记录')
         return false
       }
       data.forEach((item) => {
        let obj = {serialNo:this.formData.changeExplains.length+1}
        obj = {
          ...obj,
          ...item,
        }
        this.formData.changeExplains=this.formData.changeExplains.concat(obj)
      })
      return this.formData.changeExplains
    },
    // 删除全部变更说明
    deleteAllChangeExplains(){
      this.formData.changeExplains=[]
    },
    // 上传文件
    beforeUpload(file){
      // 文件大小为0时不允许上传
      if(file.size==0){
        this.$message.error(this.$t('uploadMinLimit'))
        return false
      }
      // 检测文件大小50M以内
      const maxSize = 1024 * 1024 *50
      if (file.size > maxSize) {
        const msg = this.$t('uploadLimit').replace('__SIZE__', '50M')
        this.$message.error(msg)
        return false
      }
      // this.$message.warning(this.$t('confirmDecrypted'))
    },
    handleRemove(type,id,index){
      if (type=='vds_plan_delete') {
          this.testInfoList=this.testInfoList.filter((item) => {
         return item.fileId !== id
        })
        this.testPlanList.splice(index,1)
      }
      if (type=='vds_demand_delete') {
          this.demandInfoList=this.demandInfoList.filter((item) => {
         return item.fileId !== id
        })
        this.demandList.splice(index,1)
      }
      if (type=='vds_white_report_delete') {
          this.staticInfoList=this.staticInfoList.filter((item) => {
         return item.fileId !== id
        })
        this.staticList.splice(index,1)
      }
      if (type=='vds_util_delete') {
          this.unitInfoList=this.unitInfoList.filter((item) => {
         return item.fileId !== id
        })
        this.unitTestList.splice(index,1)
      }
      if (type=='vds_integration_delete') {
          this.integrationInfoList=this.integrationInfoList.filter((item) => {
         return item.fileId !== id
        })
        this.integrationList.splice(index,1)
      }
      if (type=='vds_report_delete') {
          this.blackTestInfoList=this.blackTestInfoList.filter((item) => {
         return item.fileId !== id
        })
        this.blackTestList.splice(index,1)
      }
      if (type=='vds_release_delete') {
          this.releaseInfoList=this.releaseInfoList.filter((item) => {
         return item.fileId !== id
        })
        this.releaseList.splice(index,1)
      }
    },
    // 上传文件
    doUpload(options,type){
      const vm = this
      vm.$confirm({
        title: vm.$t('systemTip'),
        content:vm.$t('confirmDecrypted'),
        class: 'confirmStyle',
        icon: '<Icon >',
        width: 378,
      onOk() {
        if(type=='vds_verify'){
          vm.uploading1 = true
        }
        if(type=='vds_over_verify'){
          vm.uploading2 = true
        }
        if(type=='vds_ecn_ecr'){
          vm.uploading3 = true
        }
        if(type=='vds_plan'){
          vm.uploading4 = true
        }
        if(type=='vds_demand'){
          vm.uploading5 = true
        }
        if(type=='vds_white_report'){
          vm.uploading6 = true
        }
        if(type=='vds_util'){
          vm.uploading7 = true
        }
        if(type=='vds_integration'){
          vm.uploading8 = true
        }
        if(type=='vds_report'){
          vm.uploading9 = true
        }
        if(type=='vds_release'){
          vm.uploading10 = true
        }
          // return true
      vm.getChecksum1(options.file).then(result => {
        const formData = new FormData()
        formData.append('file', options.file)
        fileUploadApi.uploadLittleFileToCloud(formData, { hashAlgorithm: 1, checksum: result, uploadType: 8 })
          .then(res => {
            let newFileInfo={
              bizName: type,
              fileId: res.data,
              fileName:options.file.name
            }
            if(type=='vds_verify'){
              vm.verifyList.push(options.file)
              vm.verifyInfoList.push(newFileInfo)
              vm.uploading1 = false
            }
            if(type=='vds_over_verify'){
              vm.overSeasList.push(options.file)
              vm.overSeasInfoList.push(newFileInfo)
              vm.uploading2 = false
            }
            if(type=='vds_ecn_ecr'){
                vm.ECNInfoList.push(newFileInfo)
                vm.ECNList.push(options.file)
                vm.uploading3 = false
            }
            if(type=='vds_plan'){
                vm.testPlanList.push(options.file)
                vm.testInfoList.push(newFileInfo)
                vm.uploading4 = false
            }
            if(type=='vds_demand'){
                vm.demandList.push(options.file)
                vm.demandInfoList.push(newFileInfo)
                vm.uploading5 = false
            }
            if(type=='vds_white_report'){
                vm.staticList.push(options.file)
                vm.staticInfoList.push(newFileInfo)
                vm.uploading6 = false
            }
            if(type=='vds_util'){
                vm.unitTestList.push(options.file)
                vm.unitInfoList.push(newFileInfo)
                 vm.uploading7 = false
            }
            if(type=='vds_integration'){
                vm.integrationList.push(options.file)
                vm.integrationInfoList.push(newFileInfo)
                vm.uploading8 = false
            }
            if(type=='vds_report'){
                vm.blackTestList.push(options.file)
                vm.blackTestInfoList.push(newFileInfo)
                vm.uploading9 = false
            }
            if(type=='vds_release'){
                vm.releaseList.push(options.file)
                vm.releaseInfoList.push(newFileInfo)
                vm.uploading10 = false
            }
            vm.$message.success(vm.$t('uploadedSuccessfully'))

          }).finally(() => {
            // this.uploading = false
          })
      }).catch(err => {
        // console.log(err)
      })
        },
        onCancel() {},
        })
    },
    // 文件完整性校验内容md5
    getChecksum1 (file) {
      return new Promise((resolve, reject) => {
        const blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice
        const spark = new SparkMD5.ArrayBuffer()
        const fileReader = new FileReader()
        fileReader.readAsArrayBuffer(blobSlice.call(file, 0, file.size))
        fileReader.onload = function (e) {
          spark.append(e.target.result)
          resolve(spark.end())
        }
        fileReader.onerror = function (err) {
          reject(err)
        }
      })
    },
    // 软件日期变化
    onChangesoftwareDate(val, formatedDate) {
      this.formData.proDate = formatedDate
    },
    // 硬件版本日期变化
    onChangeDate(val1, formatedDate) {
      this.formData.hardVersionDate = formatedDate
    },
    // （软）硬件版本日期的日期选择的禁选日期
    disabledEndDate(current) {
      return current && current > moment().endOf('day')
    },
    // 状态总结
    handleStateSum(val){
      if(val==2||val==3){
        this.$message.warning(this.$t('stateSummaryTip'))
      }
      if(val==1){
        this.isPass=true
        this.$refs['newEditForm'].clearValidate(['problemsSum']);
        this.rules.problemsSum[0].required=false
      }else{
        this.isPass=false
        this.rules.problemsSum[0].required=true
      }
    },
    //选择软件用途
    changeSoftwareUse(val){
      if(val=='SOFTWARE_RELEASE'){
        this.isSoftwareRelese=true
      }else{
        this.isSoftwareRelese=false
        this.$refs['newEditForm'].clearValidate(['softStageDetailSupplier']);
        this.formData.softStageDetailSupplier = undefined;
      }
    },
    // 清空兼容版本
    clearCompatibleVersion() {
      this.formData.compatibleVersion = undefined
      this.$refs['newEditForm'].clearValidate(['compatibleVersion']);
      this.verisonList = []
    },
    // 判断是否需要赋值
    isEqual(arr1, arr2) {
        return arr1.length === arr2.length && arr1.every((v, i) => {
        return v === arr2[i]
        })
    },
    // 请求兼容版本
    queryCompatibleVersion() {
      this.$api
        .getMcVersionList({
          ecuId: this.formData.ecuId,
          modelCode: this.formData.modelCode,
          softwareCode: this.formData.softwareCode,
          isConfigFile: this.formData.isConfigFile,
          versionNumber:this.formData.versionNumber
        })
        .then(res => {
          this.TransitList = res.data
          if (this.formData.versionNumber) {
            this.TransitList.push(this.formData.versionNumber)
          }
          // 减少赋值次数做出下面操作
          if(!this.isEqual(this.TransitList,this.verisonList)){
            this.verisonList = this.TransitList
          }
        })
    },
    // 当改变基本信息以后删除文件以后
    clearFileInfo() {
      if (this.formData['isConfigFile']) {
        this.fileList = [{ hashAlgorithm: 1 }]
        this.formData.upgradePacks = [{ hashAlgorithm: 1 }]
        this.configFile.fileObject[this.digestAlgorithm[this.formData.upgradePacks[0].hashAlgorithm]]=undefined
      } else {
        this.fileList = []
        this.disableUpload = false
        this.formData.upgradePacks = []
      }
    },
    // 获取流程图
    getProcessXmlData () {
      const { query } = this.$route
      if (query.t === '5') {
        // eslint-disable-next-line max-len
        this.$api.getFlowInstanceDetail({ businessCode: 'sw_repo_audit', businessKey: query.originalId, instanceId: query.instanceId }).then(res => {
          if (res.data) {
            this.processView.index = 'process' + Math.random
            this.processView.xmlData = res.data.bpmnXml
            this.endTime=this.$options.filters.moment(res.data.endTime)
          }
        })
      } else {
        this.$api.getSoftwareMCFlowDesinXmlData().then(res => {
          this.processView.index = 'process' + Math.random
          this.processView.xmlData = res.data
        })
      }
    },
    // 获取软件用途
    getSoftwareUse(){
      axios({
        url: '/sw-repository/apply/drop-down-box/'+this.dictCode,
        method: 'get'
      }).then(res => {
          this.softwareUseEnumArr = res.data
      })
    },
    // 获取软件用途(工程师)
    getSoftUseEngineer(){
      let dictCode='sw_repo_soft_usage_engineer'
      axios({
        url: '/sw-repository/apply/drop-down-box/'+dictCode,
        method: 'get'
      }).then(res => {
          this.softUseEngineer = res.data
      })
    },
    // 获取车型开发阶段
    getCarDevStageArr(){
      let dictCode='sw_repo_car_project_stage'
      axios({
        url: '/sw-repository/apply/drop-down-box/'+dictCode,
        method: 'get'
      }).then(res => {
          this.carDevStageArr = res.data
      })
    },
    // 获取烧写文件类名
    getDllNameArr(){
      let dictCode='sw_repo_dll_name'
      axios({
        url: '/sw-repository/apply/drop-down-box/'+dictCode,
        method: 'get'
      }).then(res => {
          this.dllNameArr = res.data
      })
    },
    // 申请接口人列表
    getApplicationPersonArr(){
      let roleId='gcy_apply_id'
      axios({
        url: '/sw-repository/apply/application/'+roleId,
        method: 'get'
      }).then(res => {
          this.engineerSupervisorList = res.data
      })
    },
    // 申请接口人列表
    getPlanningPersonArr(){
      let roleId='ghy_apply_id'
      axios({
        url: '/sw-repository/apply/application/'+roleId,
        method: 'get'
      }).then(res => {
          this.planningSupervisorList = res.data
      })
    },
    handleEngineerSupervisorChange(val){
      this.formData.contactPersonName=this.engineerSupervisorList.filter(item=>item.id==val)[0].name
    },
    handleCreatorChange(val){
      this.formData.creatorName=this.planningSupervisorList.filter(item=>item.id==val)[0].name
    },

    // 上传配置文件
    uploadConfigFile () {
      this.$refs.uploadConfigFile.upload()
    },
    // 开始上传配置文件
    handleUploadStart () {
      this.$set(this.formData.upgradePacks[0], 'fileName', this.configFile.fileObject.fileName)
    },
    // 配置文件上传成功
    handleUploadDone () {
      const vm = this
      vm.$set(vm.formData.upgradePacks[0], 'fileId', vm.configFile.fileObject.fileId)
      vm.$set(vm.formData.upgradePacks[0], 'configFile', vm.configFile)
    },
    // 上传配置文件成功以后更改摘要算法
    handleConfigHashAlgorithmChange () {
      const vm = this
      if (vm.configFile.fileObject[vm.digestAlgorithm[vm.formData.upgradePacks[0].hashAlgorithm]]) {
        // eslint-disable-next-line max-len
        vm.$set(vm.formData.upgradePacks[0], 'checksum', vm.configFile.fileObject[vm.digestAlgorithm[vm.formData.upgradePacks[0].hashAlgorithm]])
        // eslint-disable-next-line max-len
        vm.$set(vm.formData.upgradePacks[0], 'rightChecksum', vm.configFile.fileObject[vm.digestAlgorithm[vm.formData.upgradePacks[0].hashAlgorithm]])
      }
    },
    changeReprogramType(val){
       const vm = this
        const validateVersionQuery = {
            ecuId: vm.formData.ecuId,
            modelCode: vm.formData.modelCode,
            softwareCode: vm.formData.softwareCode,
            versionNumber: vm.formData.versionNumber,
            upgradePackType: vm.formData.upgradePackType,
            isConfigFile: vm.formData.isConfigFile,
            ecuReprogramType: val,
            encryptType:vm.encryptType,
            opeartion:vm.opeartion,
          }
           vm.$api.validateReprogramType(validateVersionQuery).then(res => {
            if (res.data.illegalFlag) {
              vm.$message.warning(res.data.illegalMsg)
              vm.$set(this.formData, 'versionNumber', undefined)
              vm.$set(this.formData, 'ecuReprogramType', undefined)
            }
           }).catch(err => {
             vm.$set(this.formData, 'ecuReprogramType', undefined)
        })
    },
    // 点击保存按钮
    handleSubmit () {
      const vm = this
      vm.formData.files=[...this.overSeasInfoList,...this.ECNInfoList,...this.testInfoList,
      ...this.demandInfoList,...this.staticInfoList,...this.unitInfoList,...this.integrationInfoList,...this.blackTestInfoList,...this.releaseInfoList]
      if (this.formData.notice && this.formData.technicalFeature) {
        vm.formData.files = [...this.verifyInfoList, ...vm.formData.files];
      }
      vm.$refs.newEditForm.validate(valid => {
        // $route.query.t === 5 代表加工失败的表单
        // upgradePackType === 2 代表升级包类型为差分包
        if (vm.$route.query.t === '5' && vm.formData.upgradePackType === 2) {
            vm.$refs['newEditForm'].clearValidate(['compatibleVersion']);
        }
        if (vm.formData.upgradePacks.length < 1) {
          vm.$message.warning(vm.$t('pleaseUpload') + vm.$t('file'))
          vm.saving = false
          return
        }
        if (vm.formData.changeExplains.length < 1) {
          vm.$message.warning(vm.$t('pleaseInput') + vm.$t('softwareChangeDescription'))
          return
        }
        if (vm.blackTestInfoList.length < 1||vm.releaseInfoList.length < 1) {
          vm.$message.warning(vm.$t('pleaseInput') + vm.$t('testInformation'))
          return
        }
         if(vm.formData.carDevStage=='SOP'&&vm.ECNInfoList.length < 1){
          this.$message.warning('ECN/ECR/DCN文档未上传')
          return
        }

        if (valid) {
          // if (vm.$route.query.t === '5') {
          //   delete vm.formData.candidates
          // } else {
            const auditConfigData = vm.$refs.auditProcessRef.getConfigsData()
            if (auditConfigData.length === 0) {
              return
            }
            vm.formData.candidates = auditConfigData === 'noNeedRole' ? [] : auditConfigData
          // }
          if (vm.formData.isConfigFile) {
            // 如果是自动填充需要用生成的摘要值
            if (!vm.isManualEntry) {
              // eslint-disable-next-line max-len
              vm.formData.upgradePacks[0].checksum = vm.configFile.fileObject[vm.digestAlgorithm[vm.formData.upgradePacks[0].hashAlgorithm]]
            }
            if(vm.formData.upgradePacks[0].fileName == undefined) {
              // 提示：请上传配置文件
              vm.$message.warning(vm.$t('pleaseUpload') + vm.$t('configFile'))
              return
            }
            if (vm.formData.upgradePacks[0].checksum == undefined || (vm.isManualEntry && vm.formData.upgradePacks[0].checksum !== vm.configFile.fileObject[vm.digestAlgorithm[vm.formData.upgradePacks[0].hashAlgorithm]])) {
              // 提示：摘要值不一致
              vm.$message.warning(vm.$t('summaryIn'))
              return
            }
            // if (vm.formData.upgradePacks[0].checksum !== vm.lastestChcksum) {
            //   vm.$message.warning(vm.$t('summaryIn'))
            //   return
            // }
          }
          const validatePrimitiveVersion = []
          vm.formData.upgradePacks.forEach(item => {
            if (item.primitiveVersion) {
              validatePrimitiveVersion.push(item.primitiveVersion)
            }
          })
          const validateVersionQuery = {
            ecuId: vm.formData.ecuId,
            modelCode: vm.formData.modelCode,
            softwareCode: vm.formData.softwareCode,
            versionNumber: vm.formData.versionNumber,
            upgradePackType: vm.formData.upgradePackType,
            isConfigFile: vm.formData.isConfigFile,
            primitiveVersion: validatePrimitiveVersion,
            ecuReprogramType: vm.formData.ecuReprogramType,
          }
          if (vm.$route.query.t === '5') {
            validateVersionQuery.originId = vm.$route.query.originalId
          }
          if (vm.$route.query.t === '9'||vm.$route.query.diff=== '1'||vm.formData.formFileBuilderType) {
            validateVersionQuery.formFileBuilderType = 1
          }
          vm.$api.validateVersionName(validateVersionQuery).then(res => {
            if (res.data) {
              if ((!res.data.duplicate) && (res.data.duplicateVersion.length === 0)) {
                vm.isReapt = false
              } else {
                vm.isReapt = true
                vm.saving = false
                if (res.data.duplicate) {
                  if (res.data.duplicateVersion.length > 0 && vm.formData.upgradePackType === 2) {
                    // eslint-disable-next-line max-len
                    vm.$message.warning(vm.$t('versionDupliTipDiff').replace('__NUM__', res.data.duplicateVersion.toString()))
                  } else if (res.data.duplicateVersion.length > 0 && vm.formData.isConfigFile === 0) {
                    vm.formData.versionNumber = ''
                    // eslint-disable-next-line max-len
                    vm.$message.warning(vm.$t('versionDupliTipFull').replace('__NUM__', res.data.duplicateVersion.toString()))
                  } else if (res.data.duplicateVersion.length > 0 && vm.formData.isConfigFile === 1) {
                    vm.formData.versionNumber = ''
                    // eslint-disable-next-line max-len
                    vm.$message.warning(vm.$t('versionDupliTipConfig').replace('__NUM__', res.data.duplicateVersion.toString()))
                  }
                }
              }
            }
            if (vm.isReapt === false) {
              const formData = lodash.cloneDeep(vm.formData)
              if (formData.compatibleVersion) {
                formData.compatibleVersion = formData.compatibleVersion.toString()
              }
              if (formData.ecuReprogramType) {
                formData.ecuReprogramType = formData.ecuReprogramType.toString()
              }
              formData.draftModelCode = vm.$route.query.key ? vm.$route.query.key : undefined
              formData.draftId = vm.$route.query.id && !(!!vm.$route.query.originalId) ? vm.$route.query.id : undefined
              // eslint-disable-next-line no-restricted-syntax
              for (const key in formData) {
                if (formData[key] === '') {
                  delete formData[key]
                }
              }
              vm.$confirm({
                title: vm.$t('confirmSubmitTitle'),
                content:vm.$t('confirmSubmit'),
                class: 'confirmStyle',
                icon: '<Icon >',
                width: 378,
              onOk() {
                if (vm.$route.query.t === '5') {
                  formData.ID = vm.$route.query.originalId
                  vm.$api.submitEditedForm(formData).then(() => {
                    vm.$message.success(vm.$t('save') + vm.$t('success'))
                    vm.$store
                      .dispatch('tagsView/delView', vm.$route.fullPath)
                      .then(vm.$router.replace({ path: '/mc/sf' }))
                  })
                }else if(vm.$route.query.t === '9'){
                  formData.formFileBuilderType=1
                  vm.$api.submitNewForm(formData).then(() => {
                    vm.$message.success(vm.$t('save') + vm.$t('success'))
                    vm.$store
                      .dispatch('tagsView/delView', vm.$route.fullPath)
                      .then(vm.$router.replace({ path: '/mc/sf' }))
                  })
                }else {
                  formData.applyNumber = vm.$route.query.name ? vm.$route.query.name : undefined
                  vm.$api.submitNewForm(formData).then(() => {
                    vm.$message.success(vm.$t('save') + vm.$t('success'))
                    vm.$store
                      .dispatch('tagsView/delView', vm.$route.fullPath)
                      .then(vm.$router.replace({ path: '/mc/sf' }))
                  }).finally(()=>{
                    this.saving = false
                  })
                }
              },
              onCancel(){

              },
            })
            }
          })
        }else {
          vm.saving = false
        }
      });
      // }
    },
    // 主程序信息-表格选择更改
    onSelectChange(selectedRowKeys, selectedRows) {
      this.dataSelectedTransit = selectedRows
      this.selectedRowKeys = selectedRowKeys
      // this.formData.applyIds = selectedRows.map(item => {
      //   return item.id
      // })
    },
    // 清空搜索条件并重新搜索//重置按钮
    handleClear() {
      this.searchRelatedFormName = ''
      this.searchRelatedForm({ applyNumber: this.searchRelatedFormName })
      this.selectedRowKeys = []
    },
    // 添加选中 去重
    addChecked () {
      if (this.dataSelectedTransit.length!==0) {
      this.dataSelected.push(...this.dataSelectedTransit)
      const newdata = this.dataSelected.map(item => (JSON.stringify(item)))
      this.dataSelected = [...new Set(newdata)].map(item => (JSON.parse(item)))
      console.log(this.dataSelected,'this.dataSelected')
      this.formData.applyIds = this.dataSelected.map(item => {
        return item.id
      })
      }
    },
    // 删除已选中
    deleteSelected (data) {
      this.dataSelected = this.dataSelected.filter((item)=>{
        return item.id !== data.id
      })
      this.formData.applyIds=this.formData.applyIds.filter((item)=>{
        return item !==data.id
      })
    },
    // 清空选择
    bulkDeletion () {
      this.dataSelected = []
      this.formData.applyIds = []
    },
    // 分页
    changePage (page) {
      this.pageInfo.pageNo = page
      this.loadData()
    },
    showSizeChange (current, size) {
      this.pageInfo.pageSize = size
      this.pageInfo.pageNo = 1
      this.loadData()
    },
    loadData() {
      // 只查进行中的任务
      this.lists = []
      let params = {
        pageSize: this.pageInfo.pageSize,
        pageNo: this.pageInfo.pageNo,
      }
      this.$api.getSoftwareMCList({ shelveStatus: 10, modelCode: this.formData.modelCode, ecuId: this.formData.ecuId, applyNumber: this.searchRelatedFormName, isConfigFile: 0,pageSize:this.pageInfo.pageSize,pageNo: this.pageInfo.pageNo  }).then(res => {
        this.dataFormTb = res.data
        this.pageInfo.totalCount = res.totalCount
        this.pageInfo.totalPage = res.totalPage
      }).finally(() => {
      })
    },
    // 点击取消按钮
    handleCancel() {
      const vm = this
      vm.$store.dispatch('tagsView/delView', this.$route.fullPath).then(() => {
        if (vm.$route.query.t === '3') {
          vm.$router.replace({ path: '/todo/myDraft' })
        } else {
          vm.$router.replace({ path: '/mc/sf' })
        }
      })
    },
    // 表单重新编辑点击取消按钮返回查看详情
    cancelReedit () {
      const vm = this
      vm.$store.dispatch('tagsView/delView', this.$route.fullPath).then(() => {
        this.$router.push({ path: '/todo/applicationContent',
        query: {
          id: this.$route.query.id,
          swcode: this.$route.query.swcode,
          key: this.$route.query.originalId,
          toReview:1,
          // 是从我的申请跳转过去还是从我的审核跳转过去，会影响底部的操作信息栏加载
          aorr: 'a',
          status: this.$route.query.status } })
      })
    },
    // 表单重新编辑点击取消按钮返回操作栏
    cancelReeditAction (){
      const vm = this
      vm.$store.dispatch('tagsView/delView', this.$route.fullPath).then(() => {
        this.$router.push({ path: '/todo/myApplication' })
      })
    },
    // 废止
    fz(){
      const that = this
      const h = this.$createElement
      this.$confirm({
        title: that.$t('repealTip'),
        content: h('div', [h('b',that.$t('repealContent') ), h('p', that.$t('repealContent2'))]),
        onOk () {
          that.$api.repealForm({ instanceId: that.$route.query.id }).then(
            () => {
              that.$store.dispatch('tagsView/delView', that.$route.fullPath).then(() => {
                that.$router.replace({ path: '/todo/myApplication' })
              })
            }
          )
        },
        onCancel () { }
      })
    },
    // 点击存为草稿按钮
    handleSubmitAsDraft:debounce(function() {
      // console.log(this.formData.applyIds,'66666666')
      const vm = this
      this.formData.files=[...this.overSeasInfoList,...this.ECNInfoList,...this.testInfoList,
      ...this.demandInfoList,...this.staticInfoList,...this.unitInfoList,...this.integrationInfoList,...this.blackTestInfoList,...this.releaseInfoList]
      if (this.formData.notice && this.formData.technicalFeature) {
        vm.formData.files = [...this.verifyInfoList, ...vm.formData.files];
      }

      if (this.$route.query.t === '3') {
        const auditConfigData = this.$refs.auditProcessRef.getConfigsData(true)
        this.formData.candidates = auditConfigData === 'noNeedRole' ? [] : auditConfigData
        const formData = lodash.cloneDeep(this.formData)
        // eslint-disable-next-line no-restricted-syntax
        for (const key in formData) {
          if (formData[key] === '') {
            delete formData[key]
          }
        }
        debounce(function() {},500)
        this.$api.saveAsDraft({
          draftId: this.$route.query.id,
          draftModelCode: this.$route.query.key,
          businessContent: JSON.stringify(formData),
          modelCode: formData.modelCode,
          modelName: formData.modelName
        }).then(() => {
          vm.$message.success(vm.$t('save') + vm.$t('success'))
          vm.$store.dispatch('tagsView/delView', this.$route.fullPath)
            .then(() => {
              if (vm.$route.query.t === '3') {
                vm.$router.replace({ path: '/todo/myDraft' })
              } else {
                vm.$router.replace({ path: '/mc/sf' })
              }
            })
          })
      } else {
        if (this.$route.query.t === '9') {
         this.formData.formFileBuilderType = 1
         this.formData.ID = this.$route.query.originalId
         this.formData.selectedVersion=this.selectedVersion
        }
        const auditConfigData = this.$refs.auditProcessRef.getConfigsData(true)
        this.formData.candidates = auditConfigData === 'noNeedRole' ? [] : auditConfigData
        const formData = lodash.cloneDeep(this.formData)
        // eslint-disable-next-line no-restricted-syntax
        for (const key in formData) {
          if (formData[key] === '') {
            delete formData[key]
          }
        }
        this.$api.saveAsDraft({
          businessContent: JSON.stringify(formData),
          modelCode: formData.modelCode,
          modelName: formData.modelName
        }).then(() => {
          vm.$message.success(vm.$t('save') + vm.$t('success'))
          vm.$store.dispatch('tagsView/delView', this.$route.fullPath)
            .then(vm.$router.replace({ path: '/mc/sf' }))
        })
      }
    },500),
    // 上传提交
    uploadOk(formUploadFile) {
      for(let i=0;i<this.fileList.length;i++){
        if(this.fileList[i].primitiveVersion==formUploadFile.primitiveVersion){
          this.$message.warning('不可上传相同的原始版本的差分包')
          return
        }
      }
      if (!formUploadFile.primitiveVersion) {
        this.disableUpload = true
      }
      // debugger
      // console.log(typeof(this.formData.compatibleVersion),'wahhhhh')
      if(this.formData.compatibleVersion==undefined){
        this.formData.compatibleVersion=[]
      }
      if(formUploadFile.primitiveVersion!=undefined){
        this.formData.compatibleVersion.push(formUploadFile.primitiveVersion)
      }
      formUploadFile.fileReprogramType=this.formData.dllName
      this.fileList.push(formUploadFile)
      this.formData.upgradePacks = this.fileList
    },
    // tooltip悬浮
    getPopupContainer () {
       return document.querySelector('.ant-modal-wrap') || document.body
    },
    // 点击上传文件
    handleAddFile() {
      if (this.formData.upgradePackType === 1) {
        this.$refs.uploadFile.addFiles()
      } else if (this.formData.upgradePackType === 2) {
        if (!this.formData.modelCode || !this.formData.ecuId || !this.formData.softwareCode) {
          this.$message.warning(this.$t('firstSelectUpInfo'))
        } else {
          this.$refs.uploadFile.addFiles()
        }
      } else {
        this.$message.warning(this.$t('firstSelectUpdatePack'))
      }
    },
    // 点击在线差分
    handleOnlineDiff(){
      if(this.$route.query.t === '5'||this.$route.query.t === '3'){
        this.$refs.onlineDifference.show(true,this.targetId)
      }else{
        this.$refs.onlineDifference.show(true,this.$route.query.originalId)
      }
    },
    // 更改是否为配置文件时立马提醒用户会引起其他更改，让其再次确认
    showComfirm() {
      const vm = this
      vm.$confirm({
        title: vm.$t('systemTip'),
        content: vm.$t('editDraftTip').replace('__NAME__', vm.$t('isConfigFile')),
        class: 'confirmStyle',
        icon: '<Icon >',
        width: 378,
        onOk() {
          if (vm.formData['isConfigFile']) {
            // 如果用户选择是配置文件
            vm.clearCompatibleVersion()
            vm.fileList = [{ hashAlgorithm: 1 }]
            vm.formData.upgradePacks = [{ hashAlgorithm: 1 }]
            vm.triggerWatch = false
            if (vm.formData.softwareCode) {
              vm.formData.softwareCode = undefined
            } else {
              vm.triggerWatch = true
            }
            if (vm.formData.ecuId) {
              vm.getSoftwareOptions()
            }
            vm.disableUpload = false
            vm.isUpdateFile = false
            vm.$api.searchFlushTypeRelated(1).then(res => {
              vm.flushTypeEnumArr2 = res.data
              vm.formData.ecuReprogramType = []
              vm.disableFlushBtn = false
            })
            vm.searchRelatedForm()
            vm.formData.hardVersion = ''
            vm.formData.hardVersionDate = null
            vm.formData.bootVer = ''
            vm.$set(vm.formData,'upgradePackType',undefined)
            vm.disablePackage=false
            vm.$refs.newEditForm.clearValidate()
          } else {
            // 如果用户选择不是配置文件
            vm.clearCompatibleVersion()
            vm.triggerWatch = false
            if (vm.formData.softwareCode) {
              vm.formData.softwareCode = undefined
            } else {
              vm.triggerWatch = true
            }
            if (vm.formData.ecuId) {
              vm.getSoftwareOptions()
            }
            if (vm.$route.query.t === '3' && vm.loadDraftDone) {
              vm.triggerWatch = false
              vm.$set(vm.formData,'upgradePackType',undefined)
            } else if (vm.$route.query.t !== '3') {
              if (vm.formData.upgradePackType) {
                vm.triggerWatch = false
                vm.$set(vm.formData,'upgradePackType',undefined)
              }
            }
            vm.formData.ecuReprogramType = []
            vm.disableFlushBtn = true
            vm.isUpdateFile = true
            vm.fileList = []
            vm.formData.upgradePacks = []
            vm.disableUpload = false
            vm.$refs.newEditForm.clearValidate()
          }
        },
        onCancel() {
          vm.formData.isConfigFile = vm.formData.isConfigFile ? 0 : 1
        }
      })
    },
    check(){
      this.queryCompatibleVersion()
    },
    // 在输入框获取焦点以后，计入当前的值
    beforeEditRecordData(formKey) {
      // if ((this.$route.query.t === '3'&& this.loadDraftDone)|| this.$route.query.t === '5') {
      if ((this.$route.query.t === '3'&& this.loadDraftDone)|| this.$route.query.t === '5') {
        this[formKey] = this.formData[formKey]
      }
      // 在下拉框获取焦点时调用一次，获取下拉框数据
      this.queryCompatibleVersion()
    },
    // 在输入框失去焦点以后，判断值是否改变，如果改变要提醒用户
    // afterEditRecordData(formKey, transKey) {
      // if ((this.$route.query.t === '3'&& this.loadDraftDone)|| this.$route.query.t === '5')  {
      // if (this.$route.query.t === '5')  {
      //   if (this.formData[formKey] !== this.tempRecord) {
      //     this.confimrEditDraftBasicInfo(formKey, transKey, this.tempRecord)
      //   }
      // }
    // },
    // 二次确认是否编辑草稿的基本信息
    confimrEditDraftBasicInfo(keyName, titleName, oldVal) {
      const vm = this
      vm.$confirm({
        title: vm.$t('systemTip'),
        content: vm.$t('editDraftTip').replace('__NAME__', vm.$t(titleName)),
        class: 'confirmStyle',
        icon: '<Icon >',
        width: 378,
        onOk() {
          vm.clearFileInfo()
          if(vm.formData.upgradePackType){
             vm.disableUpload=false
          }
          if (keyName === 'upgradePackType') {
            if (vm.$route.query.t !== '3') {
              vm.fileList = []
              vm.formData.upgradePacks = []
            }
            vm.disableUpload = false
            if (vm.formData.upgradePackType === 2) {
              vm.$api.searchFlushTypeRelated(2).then(res => {
                vm.formData.ecuReprogramType = []
                vm.flushTypeEnumArr2 = res.data
                vm.disableFlushBtn = false
              })
            }
            if (vm.formData.upgradePackType === 1) {
              vm.$api.searchFlushTypeRelated(1).then(res => {
                vm.formData.ecuReprogramType = []
                vm.flushTypeEnumArr2 = res.data
                vm.disableFlushBtn = false
              })
            }
            vm.formData.compatibleVersion=[]
          }
        },
        onCancel () {
          if (keyName === 'upgradePackType' || keyName === 'ecuId' || keyName === 'softwareCode') {
            vm.triggerWatch = false
          }
          vm.formData[keyName] = oldVal
        }
      })
    },
    arrayBufferToWordArray(value) {
      const i8a = new Uint8Array(value)
      const a = []
      for (let i = 0; i < i8a.length; i += 4) {
        a.push((i8a[i] << 24) | (i8a[i + 1] << 16) | (i8a[i + 2] << 8) | i8a[i + 3])
      }
      return CryptoJS.lib.WordArray.create(a, i8a.length)
    },
    // 搜索关联主程序表单
    handleSearchForm() {
      this.searchRelatedForm({ applyNumber: this.searchRelatedFormName })
    },
    // 搜索关联主程序表单
    searchRelatedForm (query = {}) {
      if (this.formData.modelCode && this.formData.ecuId!=undefined) {
      // eslint-disable-next-line max-len
        this.$api.getSoftwareMCList({ shelveStatus: 10, modelCode: this.formData.modelCode, ecuId: this.formData.ecuId, ...query, isConfigFile: 0,pageSize:this.pageInfo.pageSize,pageNo: this.pageInfo.pageNo  }).then(res => {
          this.dataFormTb = res.data
          this.pageInfo.totalCount = res.totalCount
          this.pageInfo.totalPage = res.totalPage
          if(!(['3','5'].includes(this.$route.query.t))){
            this.formData.applyIds = []
          }
        })
      } else {
        this.dataFormTb = []
        // this.selectedRowKeys = []
        if(!(['3','5'].includes(this.$route.query.t))){
            this.formData.applyIds = []
          }
      }
    },
    // 获取上传文件内容md5
    getChecksum(file) {
      const vm = this
      return new Promise((resolve, reject) => {
        if (vm.formData.upgradePacks[0].hashAlgorithm === 2) {
          const blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice
          const sha256 = CryptoJS.algo.SHA256.create()
          const fileReader = new FileReader()
          fileReader.onload = function(e) {
            sha256.update(vm.arrayBufferToWordArray(e.target.result))
            const sha256res = sha256.finalize()
            const sha256Str = sha256res.toString(CryptoJS.enc.Hex).toLowerCase()
            resolve(sha256Str)
          }
          fileReader.onerror = function(err) {
            reject(err)
          }
          fileReader.readAsArrayBuffer(blobSlice.call(file, 0, file.size))
        } else if (vm.formData.upgradePacks[0].hashAlgorithm === 1) {
          const blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice
          const spark = new SparkMD5.ArrayBuffer()
          const fileReader = new FileReader()
          fileReader.readAsArrayBuffer(blobSlice.call(file, 0, file.size))
          fileReader.onload = function(e) {
            spark.append(e.target.result)
            resolve(spark.end())
          }
          fileReader.onerror = function(err) {
            reject(err)
          }
        }
      })
    },
    // 查看摘要值
    viewCheckSum(data) {
      this.checkSumToModal = data
      this.showCheckSum = true
    },
    // 编辑已上传的文件信息
    handleEditFileInfo(data, record, index) {
      this.$refs.editFile.editFiles(data, record, index)
    },
    // 删除已经上传的文件
    handleDeleteFile(data, record, index) {
      const that = this
      that.$confirm({
        title: that.$t('systemTip'),
        content: that.$t('deleteFileTip').replace('__Content__', data.fileName),
        onOk() {
          let tempVersin=that.fileList.splice(index, 1)[0].primitiveVersion
          let tempindex = that.formData.compatibleVersion.indexOf(tempVersin)
          if(that.formData.diffOriginalVersions){
            that.formData.diffOriginalVersions.forEach((item)=>{
              if(data.fileName.substring(0,data.fileName.lastIndexOf("-")) == item.originalVersionNumber){
                let index =that.selectedVersion.indexOf(item.originalBasicId)
                that.selectedVersion.splice(index, 1)
              }
            })
          }
          if(tempindex!=-1&&that.formData.compatibleVersion.length!=0&&that.formData.compatibleVersion!=undefined){
            that.formData.compatibleVersion.splice(tempindex,1)
          }
          if (that.fileList.length === 0) {
            that.disableUpload = false
          }
        },
        onCancel() {}
      })
    },
    // 获取编辑过后的文件信息
    editedOk(data) {
      this.$set(this.fileList[data.tableIndex], 'installSec', data.installSec)
      this.$set(this.fileList[data.tableIndex], 'timeoutSec', data.timeoutSec)
      this.$set(this.fileList[data.tableIndex], 'fileReprogramType', data.fileReprogramType)
    },
    // 车型切换需要清空后面的ecu和软件编码
    handleCarModelChange() {
      this.getModelData()
      this.formData.ecuId = undefined
      this.$api.getECUSelectOption({ 'code': this.formData.modelCode, selectAll: true })
        .then(response => {
          this.ecuOptionArr = response.data || []
        })
      this.clearFileInfo()
      this.formData.upgradePackType=undefined
    },
    // 根据是否为配置文件去获取不同的软件编码下拉
    getSoftwareOptions () {
      const vm = this
      vm.filterEcuList = []
      vm.$api.getAllEcu({ ecuModuleId: vm.formData.ecuId }).then((res) => {
        if(res.data[0]==undefined){
           this.$message.warning(this.$t('dqsjybsc'))
           this.formData.ecuId=undefined
        }
        vm.encryptType=res.data[0].encryptType
        vm.formData.ecuName = res.data[0].name
        vm.formData.vdsModuleId = res.data[0].vdsModuleId
        // console.log(vm.formData,'66666666')
        if (vm.formData.isConfigFile) {
          // 是配置文件的话，取的是配置文件软件编码，非必填，可能会没有如果没有就不要拼接到下拉，避免显示异常
          if (res.data[0].configSoftwareCode) {
            vm.filterEcuList = vm.filterEcuList.concat(res.data)
          } else {
            vm.filterEcuList = []
          }
        } else {
          vm.filterEcuList = vm.filterEcuList.concat(res.data)
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
.navigator{
  padding: 15px 24px;
  flex: none;
  border-bottom: 1px solid @borderColor;
  .ok {
    color: #147092 ;
    font-weight: bold;
  }
  .reject {
    color: #FF0000 ;
    font-weight: bold;
  }
  .titleBold{
    font-weight: 600;
  }
}
.card-radius{
  border-radius: 10px;
  padding: 30px 30px 30px 30px;
}
.EditSoftwareManageAndControl {
  display: flex;
  flex-direction: column;
  .EditSoftwareMCTop {
    position: relative;
    flex: 1;
    overflow: auto;
    min-width: 800px;
  }
  .EditSoftwareMCFooter {
    padding: 15px 24px;
    flex: none;
    border-top: 1px solid @borderColor;
    text-align: center;
  }
}
// ::v-deep .deepClass {
//   font-weight: 400;
//   margin-right: 38px;
//   text-align: right;
// }
// ::v-deep .ant-form-item-label {
//   font-weight: 400;
//   margin-right: 0px;
// }
::v-deep .ant-card-bordered {
  margin-bottom: 12px;
}
/deep/.ant-form-inline .ant-form-item-with-help {
  margin-bottom: 5px;
}
/deep/.ant-form-explain {
  position: absolute;
  font-size: 1rem;
}
// /deep/.ant-form-item-control {
//   line-height: 50px;
//  }
.myLabel{
  display:flex;
  justify-content: space-between;
  font-weight: bold;
  margin-bottom: -9px;
  margin-top: -12px;
}
/deep/.ant-form-item {
    label {
      font-size: 1.4rem;
      font-weight: bold;
      color: #000000;
    }
  }
/deep/.AsteriskAfter {
  .ant-form-item-label {
    & > label.ant-form-item-required::before {
     content: none;
    }

    & > label::before {
      content: none;
    }

    & > label::after {
      content: none;
    }
  }
}
.customFormModelItem2 {
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: bold;
}
.detailPaddingPage {
  padding: 12px;
}
::v-deep .ant-input[disabled] {
  color: #000;
  background-color: #f5f5f5;
  cursor: default;
  opacity: 1;
}
.set-margin {
  margin-right: 12px;
}
::v-deep .ant-upload-list-item-name {
    padding-left: 1.4rem !important;
}
.testInfo{
  // margin-top: 200px;
  // margin-bottom: 100px;
  width:100%;
  // margin-left:3%;
  border-collapse: separate;
  border-spacing: 1px;
  border-top: 1px solid #ccc !important;
  border-left: 1px solid #ccc !important;
  td,tr{
  border-right: 1px solid #ccc !important;
  border-bottom: 1px solid #ccc !important;
  }
  .td1{
    font-weight: 600;
    width:200px;
    text-align: right;
  };
  .td2{
    width:calc(100% - 440px);
    text-align: center;
  };
  .td3{
    width:280px;
     text-align: center;
  }
}
.fujianBtn{
  display: flex;
  align-items: center;
}
.mr8{
  margin-right:8px;
  white-space: nowrap
}
.tag{
  padding: 5px;
  height: 20px;
  border: 1px solid #649eb3;
  border-radius:16px ;
  color: #649eb3;
  a{
    display: inline-block;
    height: 20px;
    padding-right:5px ;
  }
  i{
    display: inline-block;
    cursor: pointer;
  }
}
 .tip {
        position: absolute;
        bottom: -38px;
        right: 10px;
        font-size: 0.8em;
        color: #ccc;
    }
</style>
